pll_get_term_language

Returns the term language.

Description

(bool|string) pll_get_term_language( (int) $term_id, (string) $field = 'slug' ); 

Returns (bool|string)

the requested field for the term language, false if no language is associated to that term

Parameters (2)

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

Usage

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

Defined (1)

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

/include/api.php  
  1. function pll_get_term_language( $term_id, $field = 'slug' ) { 
  2. return ( $lang = PLL()->model->term->get_language( $term_id ) ) ? $lang->$field : false;