Advertisement
htdat

Add WPML switcher to a specific menu

Sep 28th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. function new_nav_menu_items($items,$args) {
  2. // uncomment this to find your theme's menu location
  3. //echo "args: <pre>"; print_r($args); echo "</pre>";
  4.     if (function_exists('icl_get_languages') && $args->theme_location == 'CHANGE-LOCATION-HERE') {
  5.         $languages = icl_get_languages('skip_missing=0');
  6.             if(1 < count($languages)){
  7.                     foreach($languages as $l){
  8.                         if(!$l['active']){
  9.                         $items = $items.'<li class="menu-item"><a href="'.$l['url'].'">'.$l['native_name'].'</a></li>';
  10.                         }
  11.                     }
  12.                 }
  13.             }
  14.         return $items;
  15.     }
  16. add_filter( 'wp_nav_menu_items', 'new_nav_menu_items',10,2 );
  17. //Ticket: https://wpml.org/forums/topic/language-switcher-shows-up-in-both-menus-and-unable-to-remove-it/#post-480238
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement