Advertisement
shekhar77

Language switcher infront of the menu

Oct 17th, 2016
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. function new_nav_menu_items($items, $args) {
  2. $languages = apply_filters( 'wpml_active_languages', NULL, 'skip_missing=0' );
  3. if ( $languages && $args->theme_location == 'primary') {
  4. if(!empty($languages)){
  5. foreach($languages as $l){
  6. if(!$l['active']){
  7. $items = '<li class="menu-item"><a href="' . $l['url'] . '"><img src="' . $l['country_flag_url'] . '" height="12" alt="' . $l['language_code'] . '" width="18" /> ' . $l['native_name'] . '</a>' . $items;
  8. }
  9. }
  10. }
  11. }
  12. return $items;
  13. }
  14. add_filter('wp_nav_menu_items', 'new_nav_menu_items', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement