bb_get_last_post

The BuddyPress bb get last post function.

Description

bb_get_last_post( (constant) $_topic = false, (bool) $author_cache = true ); 

Parameters (2)

0. $topic (constant)
The topic.
1. $author_cache — Optional. (bool) => true
The author cache.

Usage

  1. if ( !function_exists( 'bb_get_last_post' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-posts.php'; 
  3.  
  4. // The topic. 
  5. $topic = null; 
  6.  
  7. // The author cache. 
  8. $author_cache = true; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bb_get_last_post($topic, $author_cache); 
  12.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-posts.php  
  1. function bb_get_last_post( $_topic = false, $author_cache = true ) { 
  2. global $topic, $bb_post; 
  3. if ( !$_topic ) 
  4. $topic_id = (int) $topic->topic_id; 
  5. else if ( is_object($_topic) ) 
  6. $topic_id = (int) $_topic->topic_id; 
  7. else if ( is_numeric($_topic) ) 
  8. $topic_id = (int) $_topic; 
  9.  
  10. if ( !$topic_id ) 
  11. return false; 
  12.  
  13. $_topic = get_topic( $topic_id ); 
  14.  
  15. if ( $post = bb_get_post( $_topic->topic_last_post_id ) ) { 
  16. if ( $author_cache ) 
  17. bb_post_author_cache( array($post) ); 
  18. $bb_post = $post; 
  19.  
  20. return $post;