bbp_forum_get_subforums

Return subforums of given forum.

Description

bbp_forum_get_subforums( (string) $args = '' ); 

Parameters (1)

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

Options

    ;        


    Usage

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

    Defined (1)

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

    /includes/forums/template.php  
    1. function bbp_forum_get_subforums( $args = '' ) { 
    2.  
    3. // Use passed integer as post_parent 
    4. if ( is_numeric( $args ) ) 
    5. $args = array( 'post_parent' => $args ); 
    6.  
    7. // Setup possible post__not_in array 
    8. $post_stati[] = bbp_get_public_status_id(); 
    9.  
    10. // Super admin get whitelisted post statuses 
    11. if ( bbp_is_user_keymaster() ) { 
    12.  
    13. // Not a keymaster, so check caps 
    14. } else { 
    15.  
    16. // Check if user can read private forums 
    17. if ( current_user_can( 'read_private_forums' ) ) { 
    18. $post_stati[] = bbp_get_private_status_id(); 
    19.  
    20. // Check if user can read hidden forums 
    21. if ( current_user_can( 'read_hidden_forums' ) ) { 
    22. $post_stati[] = bbp_get_hidden_status_id(); 
    23.  
    24. // Parse arguments against default values 
    25. $r = bbp_parse_args( $args, array( 
    26. 'post_parent' => 0,  
    27. 'post_type' => bbp_get_forum_post_type(),  
    28. 'post_status' => implode( ', ', $post_stati ),  
    29. 'posts_per_page' => get_option( '_bbp_forums_per_page', 50 ),  
    30. 'orderby' => 'menu_order title',  
    31. 'order' => 'ASC',  
    32. 'ignore_sticky_posts' => true,  
    33. 'no_found_rows' => true 
    34. ), 'forum_get_subforums' ); 
    35. $r['post_parent'] = bbp_get_forum_id( $r['post_parent'] ); 
    36.  
    37. // Create a new query for the subforums 
    38. $get_posts = new WP_Query(); 
    39.  
    40. // No forum passed 
    41. $sub_forums = !empty( $r['post_parent'] ) ? $get_posts->query( $r ) : array(); 
    42.  
    43. return (array) apply_filters( 'bbp_forum_get_subforums', $sub_forums, $r );