I'm using WordPress MultiLanguage Plugin and I want to know what is the language of a specific element, page or post.
I do have the
id but I want to obtain the language.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
From The WPML website:
Language constants WPML defines the following constants which can be used in the theme: Constant Description Example ICL_LANGUAGE_CODE Code for the current language fr ICL_LANGUAGE_NAME Name of current language, in the current language Français ICL_LANGUAGE_NAME_EN Name of the current language name in English French
To get the language of a specific post or page, you can use
wpml_get_language_information(). This returns an array with the following indexes:
$language_information = wpml_get_language_information($post_id); $locale = $language_information['locale'];
I have found this function via andreas.n on the WPML Forums.