bbp_has_forums( array $args = array() )
The main forum loop.
Description Description
WordPress makes this easy for us.
Parameters Parameters
- $args
-
(Optional) All the arguments supported by WP_Query
Default value: array()
Return Return
(object) Multidimensional array of forum information
Source Source
File: includes/forums/template.php
function bbp_has_forums( $args = array() ) { // Forum archive only shows root if ( bbp_is_forum_archive() ) { $default_post_parent = 0; // User subscriptions shows any } elseif ( bbp_is_subscriptions() ) { $default_post_parent = 'any'; // Could be anything, so look for possible parent ID } else { $default_post_parent = bbp_get_forum_id(); } $default_forum_search = bbp_sanitize_search_request( 'fs' ); // Default argument array $default = array( 'post_type' => bbp_get_forum_post_type(), 'post_parent' => $default_post_parent, 'post_status' => bbp_get_public_status_id(), 'posts_per_page' => get_option( '_bbp_forums_per_page', 50 ), 'orderby' => 'menu_order title', 'order' => 'ASC', 'no_found_rows' => true, 'ignore_sticky_posts' => true, // Conditionally prime the cache for last active posts 'update_post_family_cache' => true ); // Only add 's' arg if searching for forums // See https://bbpress.trac.wordpress.org/ticket/2607 if ( ! empty( $default_forum_search ) ) { $default['s'] = $default_forum_search; } // Parse arguments with default forum query for most circumstances $r = bbp_parse_args( $args, $default, 'has_forums' ); // Run the query $bbp = bbpress(); $bbp->forum_query = new WP_Query( $r ); // Maybe prime last active posts if ( ! empty( $r['update_post_family_cache'] ) ) { bbp_update_post_family_caches( $bbp->forum_query->posts ); } // Filter & return return apply_filters( 'bbp_has_forums', $bbp->forum_query->have_posts(), $bbp->forum_query ); }
Changelog Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |