bbp_has_forums

The main forum loop.

Description

(object) bbp_has_forums( (string) $args = '' ); 

WordPress makes this easy for us.

Returns (object)

Multidimensional array of forum information

Parameters (1)

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

Options

    ;        


    Usage

    1. if ( !function_exists( 'bbp_has_forums' ) ) { 
    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_has_forums($args); 
    9.  

    Defined (1)

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

    /includes/forums/template.php  
    1. function bbp_has_forums( $args = '' ) { 
    2.  
    3. // Forum archive only shows root 
    4. if ( bbp_is_forum_archive() ) { 
    5. $default_post_parent = 0; 
    6.  
    7. // User subscriptions shows any 
    8. } elseif ( bbp_is_subscriptions() ) { 
    9. $default_post_parent = 'any'; 
    10.  
    11. // Could be anything, so look for possible parent ID 
    12. } else { 
    13. $default_post_parent = bbp_get_forum_id(); 
    14.  
    15. // Parse arguments with default forum query for most circumstances 
    16. $bbp_f = bbp_parse_args( $args, array( 
    17. 'post_type' => bbp_get_forum_post_type(),  
    18. 'post_parent' => $default_post_parent,  
    19. 'post_status' => bbp_get_public_status_id(),  
    20. 'posts_per_page' => get_option( '_bbp_forums_per_page', 50 ),  
    21. 'ignore_sticky_posts' => true,  
    22. 'orderby' => 'menu_order title',  
    23. 'order' => 'ASC' 
    24. ), 'has_forums' ); 
    25.  
    26. // Run the query 
    27. $bbp =bbpress); 
    28. $bbp->forum_query = new WP_Query( $bbp_f ); 
    29.  
    30. return apply_filters( 'bbp_has_forums', $bbp->forum_query->have_posts(), $bbp->forum_query );