Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: I want bp_blog_widgets.php to include only Blog 1


Burt Adsit
Participant

@burtadsit

Following the chain of functions:

<?php $posts = bp_blogs_get_latest_posts( null, $options ) ?>

to this:

function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {

global $bp;

if ( !is_numeric( $limit ) )

$limit = 5;

return BP_Blogs_Post::get_latest_posts( $blog_id, $limit );

}

gets me to this:

function get_latest_posts( $blog_id = null, $limit = 5 ) {

global $wpdb, $bp;

if ( !$bp->blogs )

bp_blogs_setup_globals();

if ( $blog_id )

$blog_sql = $wpdb->prepare( ” AND p.blog_id = %d”, $blog_id );

$post_ids = $wpdb->get_results( $wpdb->prepare( “SELECT DISTINCT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = ‘0’ AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit” ) );

for ( $i = 0; $i < count($post_ids); $i++ ) {

$posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);

}

return $posts;

}

Where I see that changing ‘null’ to ‘1’ in bp_blogs_get_latest_posts() will get me posts only from blog id 1.

Skip to toolbar