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

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


We can use the get_locale function:

if (get_locale() == 'en_GB') {    // drink tea}


To show current language, you can use:

 <?php echo $lang=get_bloginfo("language"); ?>

Plain and simple


pll_current_language

Returns the current language

Usage:

pll_current_language( $value ); 
  • $value => (optional) either name or locale or slug, defaults to slug

returns either the fullname, or the WordPress locale (just as the WordPress core function‘get_locale’ or the slug ( 2-letters code) of the current language.