Skip to:
Content

BuddyPress.org

Ticket #950: fix-bp_dtheme_show_home_blog.patch

File fix-bp_dtheme_show_home_blog.patch, 1.6 KB (added by junsuijin, 15 years ago)
  • bp-themes/bp-sn-framework/functions.php

     
    5151
    5252/* Make sure the blog index page shows under /[HOME_BLOG_SLUG] if enabled */
    5353function bp_dtheme_show_home_blog() {
    54         global $bp, $query_string;
    55        
     54        global $bp, $query_string, $paged;
     55
    5656        if ( $bp->current_component == BP_HOME_BLOG_SLUG && ( !$bp->current_action || 'page' == $bp->current_action ) ) {
    5757                $query_string = preg_replace( '/pagename=' . BP_HOME_BLOG_SLUG . '/', '', $query_string );
    58                 query_posts($query_string);
    59                
     58
     59                if ( 'page' == $bp->current_action) {
     60                        if ( !$bp->action_variables[0] || $bp->action_variables[1] || (int) $bp->action_variables[0] < 2 ) {
     61                                locate_template( array( '404.php' ), true );
     62                                die;
     63                        }
     64                        if ( $paged != (int) $bp->action_variables[0] )
     65                                $paged = (int) $bp->action_variables[0];
     66                        if ( $query_string ) $query_string .= '&';
     67                        $query_string .= 'paged=' . $paged;
     68                }
     69                query_posts( $query_string );
     70
    6071                bp_core_load_template( 'index', true );
    6172        }
    6273}
    6374add_action( 'wp', 'bp_dtheme_show_home_blog', 2 );
    6475
     76        function bp_dtheme_filter_home_query( $query ) {
     77                global $bp;
     78                if ( $bp->current_component != BP_HOME_BLOG_SLUG )
     79                        return $query;
     80                remove_filter( 'posts_request', 'bp_dtheme_filter_home_query', 0 );
     81                // nullify the initial query
     82                return;
     83        }
     84        add_filter( 'posts_request', 'bp_dtheme_filter_home_query', 0 );
     85
    6586?>
     87 No newline at end of file