Ever want to exclude your main blog from the “Blogs Directory” listing? Here’s how:
Copy bp-default/blogs/blog-loop.php to your child-theme, while maintaining the same folder structure. (If you’re using BuddyBuilder or BuddyLite, then that’s your child-theme ) Open blog-loop.php and find the following line of code (around line 22):
1 | <?php while ( bp_blogs() ) : bp_the_blog(); ?> |
Replace that line with the following and change name-of-your-blog-here to the actual site title of your main blog (or any other blog you want to exclude).
1 | <?php while ( bp_blogs() ) : bp_the_blog(); if(bp_get_blog_name() != 'name-of-your-blog-here' ) : ?> |
Finally, as we’ve added an “if” conditional after the “while” statement above, we need to close that conditional before the closing “endwhile” tag. Add the following just before the “endwhile” tag you see around line 49:
1 | <?php endif; ?> |
Save and upload the file to your child-theme. Check your directory… look ma, no blog!
Note that this little hack does not change the displayed blog total; that would require a much more lengthy hack and would also mess with the pagination, and that would require more hacks. So, let’s stop here and live with the fact that your total blog count will be off by 1.