Created
April 23, 2014 11:47
-
-
Save ivandoric/11212191 to your computer and use it in GitHub Desktop.
wordpress: WPML Custom 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
<?php | |
/*Just add this anywhere in yopur template where you want language switcher to appear. | |
This switcher just shows the flags. But you can make it work anyway you like */ | |
?> | |
<ul class="lang-switcher"> | |
<?php | |
$languages = icl_get_languages('skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str'); | |
foreach($languages as $language){ | |
$flag = $language['country_flag_url']; | |
$url = $language['url']; | |
$isActive = $language['active']; | |
$name = $language['native_name'] | |
?> | |
<li><a href="<?php echo $url; ?>" <?php if($isActive == 1){ ?> class="active" <?php } ?>> | |
<img src="<?php echo $flag; ?>" alt="<?php echo $name; ?>" /> | |
</a></li> | |
<?php } ?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment