Show only not active languages in language selector

Please add the following code to your theme’s functions.php file, just before php end tag

 
function new_nav_menu_items($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”><a href=”‘.$l[‘url’].'”>’.$l[‘native_name’].'</a></li>’;
}
}
}
}
return $items;
}
add_filter( ‘wp_nav_menu_items’, ‘new_nav_menu_items’,10,2 );

 

Advertisements

Leave a Reply :)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s