bbp_get_topic_post_count

Return total post count of a topic.

Description

(int) bbp_get_topic_post_count( (int) $topic_id = 0, (bool) $integer = false ); 

Returns (int)

Post count

Parameters (2)

0. $topic_id — Optional. (int)
Topic id
1. $integer — Optional. (bool) => false
Whether or not to format the result

Usage

  1. if ( !function_exists( 'bbp_get_topic_post_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/template.php'; 
  3.  
  4. // Optional. Topic id 
  5. $topic_id = -1; 
  6.  
  7. // Optional. Whether or not to format the result 
  8. $integer = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_get_topic_post_count($topic_id, $integer); 
  12.  

Defined (1)

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

/includes/topics/template.php  
  1. function bbp_get_topic_post_count( $topic_id = 0, $integer = false ) { 
  2. $topic_id = bbp_get_topic_id( $topic_id ); 
  3. $replies = (int) get_post_meta( $topic_id, '_bbp_reply_count', true ) + 1; 
  4. $filter = ( true === $integer ) ? 'bbp_get_topic_post_count_int' : 'bbp_get_topic_post_count'; 
  5.  
  6. return apply_filters( $filter, $replies, $topic_id );