bp_forums_get_topic_posts

Get the posts belonging to a topic.

Description

(array) bp_forums_get_topic_posts( (string) $args = '' ); 

Returns (array)

List of posts.

Parameters (1)

0. $args — Optional. (string) => ''
The args.

Options

  • topic_id (int) => 0

    ID of the topic for which posts are being fetched.

  • page (int) => 0

    Number of results to return per page. Default: 15.

array(

    /**
     * ID of the topic for which posts are being fetched.
     *
     * @type int
     */
    'topic_id' => 0,

    /**
     * Optional. Number of results to return per page. Default: 15.
     *
     * @type int
     * @optional
     */
    'page' => 0
);        


Usage

  1. if ( !function_exists( 'bp_forums_get_topic_posts' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bp-forums-functions.php'; 
  3.  
  4. // The args. 
  5. $args = array( 
  6. 'topic_id' => 0, 
  7. 'page' => 0 
  8. ); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_forums_get_topic_posts($args); 
  12.  

Defined (1)

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

/bp-forums/bp-forums-functions.php  
  1. function bp_forums_get_topic_posts( $args = '' ) { 
  2.  
  3. /** This action is documented in bp-forums/bp-forums-screens.php */ 
  4.  
  5. $defaults = array( 
  6. 'topic_id' => false,  
  7. 'page' => 1,  
  8. 'per_page' => 15,  
  9. 'order' => 'ASC' 
  10. ); 
  11.  
  12. $args = wp_parse_args( $args, $defaults ); 
  13. $query = new BB_Query( 'post', $args, 'get_thread' ); 
  14.  
  15. return bp_forums_get_post_extras( $query->results );