bp_forums_total_topic_count

Get a count of the total topics on the site.

Description

(int) bp_forums_total_topic_count(); 

Returns (int)

$count Total topic count.


Usage

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

Defined (1)

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

/bp-forums/bp-forums-functions.php  
  1. function bp_forums_total_topic_count() { 
  2. global $bbdb; 
  3.  
  4. /** This action is documented in bp-forums/bp-forums-screens.php */ 
  5.  
  6. if ( isset( $bbdb ) ) { 
  7. if ( bp_is_active( 'groups' ) ) { 
  8. $groups_table_sql = groups_add_forum_tables_sql(); 
  9. $groups_where_sql = groups_add_forum_where_sql( "t.topic_status = 0" ); 
  10. } else { 
  11. $groups_table_sql = ''; 
  12. $groups_where_sql = "t.topic_status = 0"; 
  13. $count = $bbdb->get_results( "SELECT t.topic_id FROM {$bbdb->topics} AS t {$groups_table_sql} WHERE {$groups_where_sql}" ); 
  14. $count = count( (array) $count ); 
  15. } else { 
  16. $count = 0; 
  17.  
  18. /** 
  19. * Filters the total topic count for the site. 
  20. * @since 1.5.0 
  21. * @param int $count Total topic count. 
  22. */