Tagged: ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #559995

    Hello,

    I use the code below to change the behaviour from flags to language ISO code, it works fine in the primary menu. But now I would like to change it to the secondary menu at the right top. If I enable the secondary menu in the Enfold theme options, the flags appear in the secondary menu but the code below seems to be ignored. Changing “main_menu” to “secondary_menu” does not seem to solve the issue. Please help, thanks :o)

    /*
    * WPML language code in navigation bar 
    */
    
    	if(!function_exists('avia_append_lang_flags'))
    	{
    		//first append search item to main menu
    		add_filter( 'wp_nav_menu_items', 'avia_append_lang_flags', 20, 2 );
    		add_filter( 'avf_fallback_menu_items', 'avia_append_lang_flags', 20, 2 );
    		
    		function avia_append_lang_flags( $items, $args )
    		{
    		    if ((is_object($args) && $args->theme_location == 'avia'))
    		    {
    		        global $avia_config, $sitepress;
    
    		        if(empty($avia_config['wpml_language_menu_position'])) $avia_config['wpml_language_menu_position'] = apply_filters('avf_wpml_language_switcher_position', 'main_menu');
    		        if($avia_config['wpml_language_menu_position'] != 'main_menu') return $items;
    		
    		        $languages = icl_get_languages('skip_missing=0&orderby=custom');
    		
    		        if(is_array($languages))
    		        {
    		            foreach($languages as $lang)
    		            {
    		                $currentlang = (ICL_LANGUAGE_CODE == $lang['language_code']) ? 'avia_current_lang' : '';
    		
    		                if(is_home() || is_front_page()) $lang['url'] = $sitepress->language_url($lang['language_code']);
    		
    		                $items .= "<li class='av-language-switch-item language_".$lang['language_code']." $currentlang'><a href='".$lang['url']."'>";
    				$items .= "	" .strtoupper($lang['language_code']). "";
    		                $items .= "</a></li>";
    		            }
    		        }
    		    }
    		    return $items;
    		}
    	}
    
    /*
    * End of WPML language code in navigation bar 
    */
    #560631

    Hey Jurgen!

    not sure what you are trying to achieve. Can you show us an example of the result please? you might want to ask WPML support about this as well, as they know their plugin best.

    Best regards,
    Andy

    #563143

    Hello,

    This code is used on another customers website, in the primary menu and works fine:
    http://s13.postimg.org/ovz62bpfb/primary_ok.png

    Now I am trying to achieve the same result, but in the secondary menu above and it doesn’t do a thing:
    http://s21.postimg.org/c66tvh93r/secondary_nok.png

    May be it has something to do with the “main-menu”?
    Thanks for helping me out on this!

    Best regards,
    Jurgen

    #563717
    #563763

    Hey!

    Thanks a lot for pointing us out the solution, based on WPML support.
    Please do let us know if we can do anything else for you, we will be more than happy to help!

    Cheers!
    Basilis

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘WPML Language codes in secondary menu’ is closed to new replies.