lorenz-w
4/16/2017 - 10:43 AM

Language Switcher

Language Switcher

<?php icl_post_languages(); ?>


<?php 
/* for functions.php
/* custom language switcher https://wpml.org/documentation/getting-started-guide/language-setup/custom-language-switcher/ */
          
function icl_post_languages(){
	$languages = icl_get_languages('skip_missing=0');
  	if(1 < count($languages)){
    	foreach($languages as $l){
      		if($l['active']) {
				$langs[] = '<span class="language languageActive language'.$l['language_code'].'">'.$l['language_code'].'</span>';
			}else{
				$langs[] = '<span class="language language'.$l['language_code'].'"><a href="'.$l['url'].'">'.$l['language_code'].'</a></span>';
			}
    	}
    	echo ''.join(' | ', $langs).'';
  	}
} 
?>