Skip to content

Instantly share code, notes, and snippets.

@senlin
Created April 9, 2012 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save senlin/2341203 to your computer and use it in GitHub Desktop.
Save senlin/2341203 to your computer and use it in GitHub Desktop.
wpmlforums-location-of-flags-on-navigation-bar-post-54904
// 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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment