Last active
August 29, 2015 14:23
-
-
Save erezLieberman/118db002a4bed4528a32 to your computer and use it in GitHub Desktop.
Showed the opposite language ןin WPML language switcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_custom_switcher( $items, $args ){ | |
if( $args->theme_location == 'primary' ) { | |
$languages = icl_get_languages('skip_missing=0&orderby=code'); | |
if(!empty($languages)){ | |
ob_start(); ?> | |
<?php | |
foreach($languages as $l){ | |
if( !$l['active'] ){ ?> | |
<li class="other_lang"> | |
<a href="<?php echo $l['url']; ?>"> | |
<?php echo $l['native_name'] ?> | |
</a> | |
<?php | |
} | |
} ?> | |
<?php | |
$items .= ob_get_contents(); | |
ob_end_clean(); | |
} | |
} | |
return $items; | |
} | |
add_filter( 'wp_nav_menu_items', 'my_custom_switcher', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this code to functions.php in your theme
based on this Discussion:
https://wpml.org/forums/topic/change-the-language-order-in-menu-language-switcher/