bbp_get_reply_topic_id

Return the topic id a reply belongs to.

Description

(int) bbp_get_reply_topic_id( (int) $reply_id = 0 ); 

Returns (int)

Reply's topic id

Parameters (1)

0. $reply_id — Optional. (int)
Reply id

Usage

  1. if ( !function_exists( 'bbp_get_reply_topic_id' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/replies/template.php'; 
  3.  
  4. // Optional. Reply id 
  5. $reply_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bbp_get_reply_topic_id($reply_id); 
  9.  

Defined (1)

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

/includes/replies/template.php  
  1. function bbp_get_reply_topic_id( $reply_id = 0 ) { 
  2.  
  3. // Assume there is no topic id 
  4. $topic_id = 0; 
  5.  
  6. // Check that reply_id is valid 
  7. if ( $reply_id = bbp_get_reply_id( $reply_id ) ) 
  8.  
  9. // Get topic_id from reply 
  10. if ( $topic_id = get_post_meta( $reply_id, '_bbp_topic_id', true ) ) 
  11.  
  12. // Validate the topic_id 
  13. $topic_id = bbp_get_topic_id( $topic_id ); 
  14.  
  15. return (int) apply_filters( 'bbp_get_reply_topic_id', $topic_id, $reply_id );