bb_is_first

The BuddyPress bb is first function.

Description

bb_is_first( $post_id ); 

Parameters (1)

0. $post_id
The post id.

Usage

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

Defined (1)

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

/bp-forums/bbpress/bb-includes/functions.bb-posts.php  
  1. function bb_is_first( $post_id ) { // First post in thread 
  2. global $bbdb; 
  3. if ( !$bb_post = bb_get_post( $post_id ) ) 
  4. return false; 
  5. $post_id = (int) $bb_post->post_id; 
  6. $topic_id = (int) $bb_post->topic_id; 
  7.  
  8. static $first_post; 
  9. if ( !isset( $first_post ) ) { 
  10. $where = apply_filters('bb_is_first_where', 'AND post_status = 0'); 
  11. $first_post = (int) $bbdb->get_var("SELECT post_id FROM $bbdb->posts WHERE topic_id = $topic_id $where ORDER BY post_id ASC LIMIT 1"); 
  12.  
  13. return $post_id == $first_post;