Tag Archives: language

WPML, what is the current language?

While building a wordpress theme that has multilingual support, I needed to know what the current language was for fixing some static parts of my template.

After searching a bit on the WPML site, I found a code example where you are shown howto create your own language selector menu:

I then wrote this function to get the current language of a site:

 * Function for getting the active language of the WPML plugin
 * @return the currently active language, defaulting to 'en'
function getActiveLanguage() {
  // fetches the list of languages
  $languages = icl_get_languages('skip_missing=N&orderby=KEY&order=DIR');

  $activeLanguage = 'en';

  // runs through the languages of the system, finding the active language
  foreach($languages as $language) {
    // tests if the language is the active one
    if($language['active'] == 1) {
      $activeLanguage = $language['language_code'];

  return $activeLanguage;

Just add this code to the theme’s functions.php file and you are ready to find the active language of your site!