bbp_update_forum_subforum_count

Update the forum sub-forum count.

Description

bbp_update_forum_subforum_count( (int) $forum_id = 0, (int) $subforums = 0 ); 

Parameters (2)

0. $forum_id — Optional. (int)
Forum id
1. $subforums — Optional. (int)
The subforums.

Usage

  1. if ( !function_exists( 'bbp_update_forum_subforum_count' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/functions.php'; 
  3.  
  4. // Optional. Forum id 
  5. $forum_id = -1; 
  6.  
  7. // The subforums. 
  8. $subforums = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_update_forum_subforum_count($forum_id, $subforums); 
  12.  

Defined (1)

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

/includes/forums/functions.php  
  1. function bbp_update_forum_subforum_count( $forum_id = 0, $subforums = 0 ) { 
  2. $forum_id = bbp_get_forum_id( $forum_id ); 
  3.  
  4. if ( empty( $subforums ) ) 
  5. $subforums = count( bbp_forum_query_subforum_ids( $forum_id ) ); 
  6.  
  7. update_post_meta( $forum_id, '_bbp_forum_subforum_count', (int) $subforums ); 
  8.  
  9. return (int) apply_filters( 'bbp_update_forum_subforum_count', (int) $subforums, $forum_id );