Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #214614

    Hi, I’m using the Enfold theme with small fixed header. I would like to have the language selector (two flags side by side is enough) on top of the menu (or by its side maybe?). How can I achieve this? Thank you

    João

    #214672

    Hey t-creator!

    Please add this at the very bottom of functions.php:

    if(!function_exists('avia_append_lang_flags'))
    {
    	//first append search item to main menu
    	add_filter( 'wp_nav_menu_items', 'avia_append_lang_flags', 10, 2 );
    
    	function avia_append_lang_flags( $items, $args )
    	{	
    	    if ((is_object($args) && $args->theme_location == 'avia'))
    	    {
    	        global $avia_config;
    	        global $sitepress;
    			$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='language_".$lang['language_code']." $currentlang'><a href='".$lang['url']."'>";
    					$items .= "	<span class='language_flag'><img title='".$lang['native_name']."' src='".$lang['country_flag_url']."' /></span>";
    					$items .= "</a></li>";
    				}
    			}
    	    }
    	    return $items;
    	}
    }
    

    Best regards,
    Ismael

    #215323

    Ismael, thank you very much!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘WPML Language Selector on Top’ is closed to new replies.