bp_forums_get_forum_topicpost_count

Get topic and post counts for a given forum.

Description

(object) bp_forums_get_forum_topicpost_count( (int) $forum_id ); 

Returns (object)

Object with properties $topics (topic count) and $posts (post count).

Parameters (1)

0. $forum_id (int)
ID of the forum.

Usage

  1. if ( !function_exists( 'bp_forums_get_forum_topicpost_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bp-forums-functions.php'; 
  3.  
  4. // ID of the forum. 
  5. $forum_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_forums_get_forum_topicpost_count($forum_id); 
  9.  

Defined (1)

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

/bp-forums/bp-forums-functions.php  
  1. function bp_forums_get_forum_topicpost_count( $forum_id ) { 
  2. global $wpdb, $bbdb; 
  3.  
  4. /** This action is documented in bp-forums/bp-forums-screens.php */ 
  5.  
  6. // Need to find a bbPress function that does this. 
  7. return $wpdb->get_results( $wpdb->prepare( "SELECT topics, posts from {$bbdb->forums} WHERE forum_id = %d", $forum_id ) );