[buddypress-trac] [BuddyPress] #967: unnecessary extra query caused by bp_dtheme_show_home_blog

buddypress-trac at lists.automattic.com buddypress-trac at lists.automattic.com
Wed Sep 23 04:48:48 UTC 2009


#967: unnecessary extra query caused by bp_dtheme_show_home_blog
------------------------------+---------------------------------------------
Reporter:  junsuijin          |       Owner:  junsuijin
    Type:  defect             |      Status:  new      
Priority:  major              |   Milestone:  1.1      
Keywords:  has-patch, tested  |  
------------------------------+---------------------------------------------
Changes (by junsuijin):

  * priority:  minor => major


Comment:

 As asked in #buddypress-dev, this function can indeed be extended as
 follows to remove extra queries from all bp pages, including a quick test
 of 1 query removed on the members dir, 2 gone on a logged in users
 profile, 4 gone on the forums dir:

 {{{
 function bp_filter_wp_posts_request( $query ) {
         global $bp;

         if ( $bp->current_component != BP_HOME_BLOG_SLUG &&
 bp_is_blog_page() )
                 return $query;

         // nullify the initial WordPress posts_request
         remove_filter( 'posts_request', 'bp_filter_wp_posts_request', 0 );
         return;
 }
 add_filter( 'posts_request', 'bp_filter_wp_posts_request', 0 );
 }}}

 The thing about this, is that the $bp->current_component !=
 BP_HOME_BLOG_SLUG bit is only going to necessarily apply to the bp-sn-
 parent's child themes (well really only bp-default and any others that use
 the /blog format), so we should probably make a hook at that point in the
 function, and use the bp-sn-parent functions.php to put that bit in there,
 thus allowing other themes to alter this check as necessary.

-- 
Ticket URL: <http://trac.buddypress.org/ticket/967#comment:1>
BuddyPress <http://buddypress.org/>
BuddyPress


More information about the buddypress-trac mailing list