Created
September 26, 2019 15:41
-
-
Save joviczarko/c320446870a4bbe33ebf596933e8d3a2 to your computer and use it in GitHub Desktop.
Display WPML language buttons custom with current language
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 | |
$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