Skip to content

Instantly share code, notes, and snippets.

@joviczarko
Created September 26, 2019 15:41
Show Gist options
  • Save joviczarko/c320446870a4bbe33ebf596933e8d3a2 to your computer and use it in GitHub Desktop.
Save joviczarko/c320446870a4bbe33ebf596933e8d3a2 to your computer and use it in GitHub Desktop.
Display WPML language buttons custom with current language
<?php
$languages = icl_get_languages('skip_missing=0');
if(1 < count($languages)){
echo '<ul>';
foreach($languages as $l){
if(!$l['active']) {
$lang = '<li class="lang-button"><a href="'.$l['url'].'">'.$l['language_code'].'</a></li>';
} else {
$lang = '<li class="lang-button"><a class="current-lang" href="'.$l['url'].'">'.$l['language_code'].'</a></li>';
}
echo $lang;
}
echo "</ul>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment