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.
Usage
if ( !function_exists( 'bbp_has_forums' ) ) { require_once ABSPATH . PLUGINDIR . 'bbpress/includes/forums/template.php'; } // The args. $args = ''; // NOTICE! Understand what this does before running. $result = bbp_has_forums($args);
Defined (1)
The function is defined in the following location(s).
- /includes/forums/template.php
- function bbp_has_forums( $args = '' ) {
- // 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();
- }
- // Parse arguments with default forum query for most circumstances
- $bbp_f = bbp_parse_args( $args, 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 ),
- 'ignore_sticky_posts' => true,
- 'orderby' => 'menu_order title',
- 'order' => 'ASC'
- ), 'has_forums' );
- // Run the query
- $bbp =bbpress);
- $bbp->forum_query = new WP_Query( $bbp_f );
- return apply_filters( 'bbp_has_forums', $bbp->forum_query->have_posts(), $bbp->forum_query );
- }