Skip to content

Instantly share code, notes, and snippets.

@lonchbox
Created March 10, 2016 20:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lonchbox/999616a3586f2817af71 to your computer and use it in GitHub Desktop.
Save lonchbox/999616a3586f2817af71 to your computer and use it in GitHub Desktop.
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