WPML | Custom languages selector
For a project, i need to develop a custom wpml languages selector:
For selector with languages flags only, add this directly in function.php of you theme.
[pre] /************************ */ /* Custom Language Switcher */ /********************** */
function language_selector_flags(){
$languages = icl_get_languages(‘skip_missing=0&orderby=code’);
if(!empty($languages)){
foreach($languages as $l){
if(!$l[‘active’])
echo ‘<a href=”‘.$l[‘url’].'”>’;
echo ‘<img src=”‘.$l[‘country_flag_url’].'” height=”12″ alt=”‘.$l[‘language_code’].'” width=”18″ />’; if(!$l[‘active’])
echo ‘</a>’;
}
}
}
[/pre]
and this in your theme template where you want the selector appears :
[pre]<div id="flags_language_selector"> <?php language_selector_flags(); ?> </div>[/pre]
For Selector with languages code only, add this directly in you function.php
[pre]
[/pre]
and this in your theme template where you want the selector appears :
[pre]<div id="flags_language_selector"> <?php language_selector_flags(); ?> </div>[/pre]
For selector with select box with language code. add this directly in you function.php
[pre]
[/pre]
and this in your theme template where you want the selector appears :
[pre] <div id="flags_language_selector"> <?php language_selector_flags(); ?> </div>[/pre]