pll_current_language

Returns the current language on frontend Returns the language set in admin language filter on backend ( false if set to all languages ).

Description

(string|bool) pll_current_language( (string) $field = 'slug' ); 

Returns (string|bool)

the requested field for the current language

Parameters (1)

0. $field — Optional. (string) => 'slug'
The language field to return name,, locale, defaults to slug

Usage

  1. if ( !function_exists( 'pll_current_language' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'polylang/include/api.php'; 
  3.  
  4. // optional the language field to return 'name', 'locale', defaults to 'slug' 
  5. $field = 'slug'; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pll_current_language($field); 
  9.  

Defined (1)

The function is defined in the following location(s).

/include/api.php  
  1. function pll_current_language( $field = 'slug' ) { 
  2. return isset( PLL()->curlang->$field ) ? PLL()->curlang->$field : false;