How can I get iso code language in WordPress?
This function :
get_bloginfo('language');
return me the languge like this : en-EN
I create a function like this :
<?php
function pr_language() {
$lang = get_bloginfo('language');
$pos = stripos($lang, '-');
$lang = substr(get_bloginfo('language'),0,-($pos+1)); // retourne "f"
return $lang;
}
?>
Is it correct? I want to display en not en-EN
I hope I understood your question. It seems like all you want to display is en-US.
According to WordPress,
Usage:
<?php bloginfo( $show ); ?>Parameters:
languageSo,
EXACT CODE:
<?php bloginfo('language'); ?>Will output:
To show only en, just display first two characters.
Just a note for anyone in the future:
<?php echo substr( get_bloginfo ( 'language' ), 0, 2 );?>Produced:
and
<?php echo substr( bloginfo ( 'language' ), 0, 2 );?>Produced: