Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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 );

    #996261

    Hey 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,
    Dude

    #996801

    Thanks 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)

    #997115

    Hi,

    Yes, try this code:

    
    if ((is_object($args) && $args->theme_location == 'avia2')) return $items;
    $languages = icl_get_languages('skip_missing=0');
    

    Best regards,
    Dude

    #997196

    Hello 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
    Helene

    #997241

    Hi,

    Great, glad it works now :)

    Best regards,
    Dude

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Show inactive language in MAIN Enfold Menu ONLY’ is closed to new replies.