Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine the current language of a wordpress page when using polylang?

I search for a variable that outputs the currently used language of the polylang plugin. Something like:

if($curlang == "en") {   ... } 
like image 569
Felix TheCat Avatar asked Mar 18 '15 09:03

Felix TheCat


People also ask

How can I get WordPress language?

If you are using WordPress version 4.0 or newer, log in to the WordPress administration interface. Click Settings, and then click General. In the Site Language list box, select the language you want WordPress to use, and then click Save Changes. If you are using WordPress version 3.9.

How do I translate a page in Polylang?

Simply find the row of the page you want to translate and click the + icon next to the flag of the language you want to create a translation for. Again Polylang will automatically link the new page you create to the source page, and the two pages will be considered translations of the same piece of content.

How can I get current language in Wpml?

One way to use this hook is to create a shortcode that returns the current language as the 2-letter language code. function get_language_shortcode() { return apply_filters( 'wpml_current_language', null ); } add_shortcode( 'language', 'get_language_shortcode' );


1 Answers

We can use the get_locale function:

if (get_locale() == 'en_GB') {     // drink tea } 
like image 181
Felix TheCat Avatar answered Sep 24 '22 16:09

Felix TheCat