Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WPML custom language switcher
<?php
/*
* WPML language switcher customizations: htp://wpml.org
*/
function custom_wpml_lang_switcher() {
if (function_exists('icl_get_languages')){
// remove WPML default css
define('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true);
// Custom language layout selector ?>
<div class="languages">
<ul>
<?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 class="<?php if($isActive == 1){ ?> class="active" <?php } ?>" href="<?php echo $url; ?>">
<?php echo $name; ?>
</a>
</li>
<?php } ?>
</ul>
<?php }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.