get_topic_id

The BuddyPress get topic id function.

Description

get_topic_id( (int) $id = 0 ); 

Parameters (1)

0. $id — Optional. (int)
The id.

Usage

  1. if ( !function_exists( 'get_topic_id' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-template.php'; 
  3.  
  4. // The id. 
  5. $id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_topic_id($id); 
  9.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-template.php  
  1. function get_topic_id( $id = 0 ) { 
  2. global $topic; 
  3. $id = (int) $id; 
  4. if ( $id ) 
  5. $_topic = get_topic( $id ); 
  6. else 
  7. $_topic =& $topic; 
  8.  
  9. if ( empty($_topic->topic_id) ) 
  10. return 0; 
  11.  
  12. return (int) $_topic->topic_id;