public
Created

wpmlforums-location-of-flags-on-navigation-bar-post-54904

  • Download Gist
wp_nav_menu_hor.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Filter wp_nav_menu() to add additional links and other output
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'].'"><img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /> </a></li>';
}
}
}
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items',10,2 );

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.