-
AuthorPosts
-
August 9, 2018 at 11:58 pm #995775
Hello, I updated my functions.php file with this code you gave me earlier. I used to have only one menu But now I have many custom menus in a sidebar and the inactive language appear in ALL of them. I would like to show inactive language in my MAIN Enfold Menu ONLY (set to appear in my header and my footer). Can you please help me? I am sending the link to my website in Private Content. Thanks. My Menu Name is Header Menu in English and Header Munu FR in French
/*
* show inactive language in menus
*/
function new_nav_menu_items283238($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[‘native_name’].’‘;
}
}
}
}
return $items;
}
add_filter( ‘wp_nav_menu_items’, ‘new_nav_menu_items283238’,10,2 );
August 11, 2018 at 11:00 am #996261Hey IngeniumCanada,
Replace this line of your code:
$languages = icl_get_languages('skip_missing=0');
with
if ((is_object($args) && $args->theme_location != 'avia')) return $items; $languages = icl_get_languages('skip_missing=0');
The main menu has the theme location “avia”, the secondary menu “avia2” and the footer menu “avia3”.
Best regards,
DudeAugust 13, 2018 at 6:06 pm #996801Thanks Dude. It is working perfectly. But now, if I would like the inactive language to be shown in the Footer (avia3) as well as in the main menu (avia) can you please give me the correct code and syntax? Thanks! (link to website in Private content)
August 14, 2018 at 2:54 pm #997115Hi,
Yes, try this code:
if ((is_object($args) && $args->theme_location == 'avia2')) return $items; $languages = icl_get_languages('skip_missing=0');
Best regards,
DudeAugust 14, 2018 at 6:11 pm #997196Hello Dude,
with theme_location != ‘avia’ the inactive language appears uniquely in the header, not in the footer nor my other CUSTOM Menus in the right sidebar.with theme_location == ‘avia2’ the inactive language appears in the header, the footer and in ALL my other CUSTOM Menus in the right sidebar. It has the same effect then before putting theme_location != ‘avia’
I found the way to code not avia and not avia3 and is solved the problem:
if ((is_object($args) && ($args->theme_location != ‘avia’ and $args->theme_location != ‘avia3’))) return $items;
$languages = icl_get_languages(‘skip_missing=0’);Thanks for your help
HeleneAugust 14, 2018 at 7:11 pm #997241Hi,
Great, glad it works now :)
Best regards,
Dude -
AuthorPosts
- The topic ‘Show inactive language in MAIN Enfold Menu ONLY’ is closed to new replies.