Last active
July 16, 2023 05:59
-
-
Save kirandash/a3ed2644627b858097d4b5bd97dde0cc to your computer and use it in GitHub Desktop.
Custom language switcher for the wpml plugin that shows the language code
This file contains hidden or 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 | |
// IN FUNCTIONS.PHP FILE CUSTOM LANGUAGE SWITCHER | |
function language_selector_flags(){ | |
$languages = icl_get_languages('skip_missing=0&orderby=code'); | |
if(!empty($languages)){ | |
echo '<ul class="menu language-menu">'; | |
foreach($languages as $l){ | |
if($l['active'] == 1){ $class = 'lang_sel_sel'; } | |
elseif ($l['active'] == 0) { | |
$class = 'lang_sel_other'; | |
} | |
echo '<li><a href="'.$l['url'].'" class="'.$class.'"><span>'; | |
echo strtoupper($l['language_code']); | |
echo '</span></a></li> '; | |
} | |
echo '</ul>'; | |
} | |
} | |
// TO TRIGGER | |
language_selector_flags(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment