-
AuthorPosts
-
October 25, 2016 at 6:34 pm #703913
Hi there,
I would like the WPML language switcher to display only one flag (the language not currently on display)
It seems to me that showing the flag of the language displayed anyway – is redundant.
Do you know how I would go about doing that?
my site is http://www.edoshummus.comOctober 25, 2016 at 8:24 pm #703951Hi Oren!
Please consider to contact the WPML Support team, who will be more able to help you with your issues.
Thanks a lot for your understanding
Regards,
BasilisOctober 25, 2016 at 9:15 pm #703972Hello Basilis,
As per WPM support suggestion, I added the following script to functions.php in my child theme.
function custom_languages_menu($items,$args) {
if (function_exists(‘icl_get_languages’)) {
$languages = icl_get_languages(‘skip_missing=0’);
if(1 < count($languages)){
foreach($languages as $l){
if(!$l[‘active’]) {
$items = $items.'<li class=”menu-item-‘.$l[‘language_code’].'”>‘;
}
}
}
}
return $items;
}
add_filter( ‘wp_nav_menu_items’, ‘custom_languages_menu’,10,2 );The result is an error message while loading the site. It seem to indicate that functions.php is not functioning properly.
as per another issue, you have a user with full admin rights to http://www.edoshummus.com.
Could you please take a look?Thanks a lot
Oren
October 27, 2016 at 9:16 pm #705029Hi Oren!
It seems like you removed the code already.
Can you please create a temporary admin login, FTP login and post them here privately? Also, please post the code WPML team provided using – http://pastebin.com/Best regards,
YigitOctober 27, 2016 at 10:35 pm #705057Try this
function my_theme_setup() { add_filter('wp_list_pages', 'new_nav_menu_items'); add_filter('wp_nav_menu_items', 'new_nav_menu_items'); } add_action('after_setup_theme', 'my_theme_setup'); function new_nav_menu_items($items){ if (function_exists('icl_get_languages')){ $languages = icl_get_languages('skip_missing=0'); if (count($languages) > 1){ foreach ($languages as $l) { if (!$l['active']) { $items .= "<li class='menu-item menu-item-language'>"; $items .= "<a href='{$l['url']}'>"; $items .= $l['native_name']; $items .= "</a></li>"; } } } } return $items; }
October 28, 2016 at 12:06 am #705075Hello Yigit,
The URL for WP user (admin) is http://www.edoshummus,com/wp-admin
credentials of WP and FTP are in private content.The script I tried to insert is:
function custom_languages_menu($items,$args) {
if (function_exists(‘icl_get_languages’)) {
$languages = icl_get_languages(‘skip_missing=0’);
if(1 < count($languages)){
foreach($languages as $l){
if(!$l[‘active’]) {
$items = $items.'<li class=”menu-item-‘.$l[‘language_code’].’”>’.$l[‘code’].’‘;
}
}
}
}
return $items;
}
add_filter( ‘wp_nav_menu_items’, ‘custom_languages_menu’,10,2 );This resulted in a complete lock-up of the installation, even after I removed the script. I had to restore functions.php from backup.
Thanks a lot
Oren
October 28, 2016 at 12:12 am #705079Sorry Castellanero,
This script too appears on top of the page.
I left it for Yigit to see.Best
Oren
October 28, 2016 at 3:21 am #705119Hey!
There was a closing PHP tag in the middle of your functions.php file. I removed it and re-installed Enfold parent theme. Please review your website now
Regards,
YigitOctober 28, 2016 at 2:24 pm #705306Thank you Yigit,
fubnctions.php indeed seems to work smoothly now.
However, the script still does not do what it is supposed to do – show only the flag of the alternate language.
I guess I will pick this up with the WPML team.All the best
Oren
October 28, 2016 at 2:35 pm #705314 -
AuthorPosts
- You must be logged in to reply to this topic.