Filter Home Page Posts in Buddypress

I would like to remove blog posts from the home page if they belong to a certain category. How can I go about this in Buddypress (preferably without a plugin)?

Related posts

Leave a Reply

2 comments

  1. If you mean filtering the home page activity stream by blog post category, it’s not possible using any of the buit in BuddyPress template tags, functions or queries. I struggled with this same issue for months and finally gave up. If someone can prove me wrong I would love to hear the solution.

    If your not using the activity stream on your home page you can just use the WP_Query class to filter the posts.

    My use case for filtering the blog posts in the activity stream was to have separate activity stream pages for each post category.

    The closest thing I could find was the BuddyPress Links Plugin which creates a links post type that uses categories and is integrated into the BuddyPress activity stream but it required to much customization to get it to work how I wanted.

    I also spoke with Boone at length at a WordCamp about adding custom meta or categories to any of the BuddyPress components and using the meta to filter the activity stream. He said it can be done but it would have to be completely coded from scratch and is not something nativly supported by BuddyPress. He also said the best way to accomplish this would be to create a new custom BuddyPress component.

  2. Can you explain what your trying to achieve a little bit better. Are you wanting to filter certain categories from certain users or certain categories from all users?

    EDIT:
    Here are some items i have found on this.

    Now i have not tried to see if this works as i do not currently have a buddypress site to mess with and it takes to much to get a test one up and know what your settings are

    1. This one being the hardest is to download this plugin Front Page Category Filter and grab the code out of it.
    2. According to this quote (found here):

    Just as you use “The Loop” to loop through posts in WordPress, each content type in BuddyPress has its own custom loop.

    By using these loops in your template, you can output any kind of information and really customize how content is displayed within your BuddyPress theme.

    The default BuddyPress theme (/wp-content/themes/bp-default) makes use of all the custom loops available in BuddyPress. It provides a good example of using the loops in real use situations.

    You can use WordPress custom loop’s inside a BuddyPress theme as long as it makes use of them.

    You can find the WordPress loop’s codex page by clicking here and the one you specifically need by click here

    Here is the code you would need:

    The following line <?php if ( is_home() ) { helps buddypress determine that this needs to happen only on the home page.

    <?php if ( is_home() ) { query_posts($query_string . '&cat=-3,-8');} ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <div class="post">
    
    <!-- Display the Title as a link to the Post's permalink. -->
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    
    <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
    <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
    
    <div class="entry">
    <?php the_content(); ?>
    </div>
    
    <p class="postmetadata">Posted in <?php the_category(', '); ?></p>
    </div> <!-- closes the first div box -->
    
    <?php endwhile; else: ?>
    <p>Sorry, no posts matched your criteria.</p>
    <?php endif; ?>