1

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.

closed as off-topic by Howdy_McGee Feb 2 '17 at 15:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1

From The WPML website:

http://wpml.org/documentation/support/wpml-coding-api/

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
  • It's about page language, not the language supported and i don't need this in the theme, I need this inside a plugin. – sorin Oct 4 '10 at 9:24
  • Those constants are defined at priority 1 on the 'plugins_loaded' action, using the current url's language code. I promise you, that's what you want. – John P Bloch Oct 4 '10 at 13:47
1

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:

  • locale
  • text_direction
  • display_name
  • native_name
  • different_language

Example

$language_information = wpml_get_language_information($post_id);
$locale = $language_information['locale'];

I have found this function via andreas.n on the WPML Forums.

Not the answer you're looking for? Browse other questions tagged or ask your own question.