Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: HELP: Adjust Recent Blog Widget for 2 Categories Only


Anonymous User 303747
Inactive

@anonymized-303747

gerbilo, I owe you one. Perfect!

In summary – objective was to limit the output in the Recent Blog Posts widget to only a few selected (in my case self-owned) blogs.

Edit bp-blogs-classes.php:

Replace:

$post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT 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" ) );

With

$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 IN (1,2) 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" ) );

In my example, I use blog_id 1 and blog_id 2.

I don’t like hacking the code, so if there’s anyone who knows to get this done by putting it in the mu-plugins directory and leave the BP code untouched, I’d be interested in learning about it.

Thanks again, gerbilo!

Skip to toolbar