pll_count_posts

Count posts in a language.

Description

(int) pll_count_posts( (string) $lang, (array) $args = array() ); 

Returns (int)

posts count

Parameters (2)

0. $lang (string)
Language code
1. $args — Optional. (array) => array()
( accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format )

Usage

  1. if ( !function_exists( 'pll_count_posts' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'polylang/include/api.php'; 
  3.  
  4. // language code 
  5. $lang = ''; 
  6.  
  7. // ( accepted keys: post_type, m, year, monthnum, day, author, author_name, post_format ) 
  8. $args = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = pll_count_posts($lang, $args); 
  12.  

Defined (1)

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

/include/api.php  
  1. function pll_count_posts( $lang, $args = array() ) { 
  2. return PLL()->model->count_posts( PLL()->model->get_language( $lang ), $args );