WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to "omit" certain blogs from the regular BuddyPress blog loop. Either by blog ID or blog Name is fine. Has anyone had success doing this?

share|improve this question
You could request this as a new feature to the developers of buddypress. – Wadih M. Sep 8 '10 at 14:28

Currently the bp_has_blogs() loop does not allow an exclude param to remove certain blogs from the listing. By default all public blogs are listed. You can try a simple hack (but the pagination will be off) http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/excluding-certain-blogs-from-bp_has_blogs-function-for-12/

Or you can filter on bp_has_blogs and loop over the array and unset (+ recount) prior to being displayed in the theme. While not ideal, pagination would be correct.

pseudo code for a filter: (though untested as i do run ms+bp setup - have a look at the source code file bp-blogs/bp-blogs-templatetags.php and the class BP_Blogs_Template for further info)

function my_remove_blog_from_loop( $b, $blogs ) {

foreach ( $blogs->the_blogs as $key => $blog ) {

    if ( $blog->blog_id == SOME_BLOG_ID_HERE ) {

        unset( $blogs->the_blogs[$key] );

        $blogs->blog_count = $blogs->blog_count-1;
        $blogs->total_blog_count = $blogs->total_blog_count-1;
        $blogs->pag_num = $blogs->pag_num -1;

/* Renumber the array keys to account for missing items */
$blogs_new = array_values( $blogs->blogs );
$blogs->blogs = $blogs_new;

return $blogs;
add_action('bp_has_blogs','my_remove_blog_from_loop', 10, 2 );

replace SOME_BLOG_ID_HERE which whatever numerical blog_id

share|improve this answer

Similar method works to exclude members:

function custom_remove_members( $m, $members ) {

  foreach ( $members->members as $key => $member ) {

      if ( $member->id == 1 ) {

          unset( $members->members[$key] );

          $members->member_count = $members->member_count-1;
          $members->total_member_count = $members->total_member_count-1;
          $members->pag_num = $members->pag_num-1;

  /* Renumber the array keys to account for missing items */
  $members_new = array_values( $members->members );
  $members->members = $members_new;

  return $members;


add_action('bp_has_members','custom_remove_members', 10, 2 );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.