Skip to:
Content

bbPress.org


Ignore:
Timestamp:
12/20/2012 10:46:04 AM (13 years ago)
Author:
johnjamesjacoby
Message:

In bbp_list_forums(), remove check for subforums meta, and trust the subforums query to do the work.

In the subforums query, avoid using get_posts() and use a new WP_Query object instead. Also fix some return value type-casting.

Fixes #2085.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/forums/template-tags.php

    r4579 r4597  
    643643    // Parse arguments against default values
    644644    $r = bbp_parse_args( $args, array(
    645         'post_parent'    => 0,
    646         'post_type'      => bbp_get_forum_post_type(),
    647         'post_status'    => implode( ',', $post_stati ),
    648         'posts_per_page' => get_option( '_bbp_forums_per_page', 50 ),
    649         'orderby'        => 'menu_order',
    650         'order'          => 'ASC'
     645        'post_parent'         => 0,
     646        'post_type'           => bbp_get_forum_post_type(),
     647        'post_status'         => implode( ',', $post_stati ),
     648        'posts_per_page'      => get_option( '_bbp_forums_per_page', 50 ),
     649        'orderby'             => 'menu_order',
     650        'order'               => 'ASC',
     651        'ignore_sticky_posts' => true,
     652        'no_found_rows'       => true
    651653    ), 'forum_get_subforums' );
    652654    $r['post_parent'] = bbp_get_forum_id( $r['post_parent'] );
    653655
     656    // Create a new query for the subforums
     657    $get_posts = new WP_Query();
     658
    654659    // No forum passed
    655     $sub_forums = !empty( $r['post_parent'] ) ? get_posts( $r ) : '';
    656 
    657     return apply_filters( 'bbp_forum_get_sub_forums', (array) $sub_forums, $args );
     660    $sub_forums = !empty( $r['post_parent'] ) ? $get_posts->query( $r ) : array();
     661
     662    return (array) apply_filters( 'bbp_forum_get_subforums', $sub_forums, $args );
    658663}
    659664
     
    699704    ), 'list_forums' );
    700705
    701     // Bail if there are no subforums
    702     if ( !bbp_get_forum_subforum_count( $r['forum_id'], false ) )
    703         return;
    704 
    705706    // Loop through forums and create a list
    706707    $sub_forums = bbp_forum_get_subforums( $r['forum_id'] );
Note: See TracChangeset for help on using the changeset viewer.