Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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
share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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