how to prevent a particular post category showing up in google reader blog feed

I am using a responsive slider plugin that uses posts to populate the image slider on the home page.

So I have setup posts in a category called “slides” expressly for using the featured images for the image slider.

I have set them up so that they are not listed on my blog page, and they are not showing up in my blog feed.

However in google reader, it is showing all the slides? Is there a way to block this from happening? a setting to remove the “slider” category completely from my feed?

  • aecnu
    • WP Unicorn

    Greetings davidh5,

    Thank you for bringing this item to our attention.

    You will need to place something like this in your functions.php file:

    function myFilter($query) {
    if ($query->is_feed) {
    $query->set('cat','-99');
    }
    return $query;
    }

    add_filter('pre_get_posts','myFilter');

    The number 99 refers to the index of the category you want to exclude from the feed. Do not forget to add the minus before the number you are going to put in here.

    Thank you for being a WPMU Dev Community Member!

    Cheers, Joe

  • David T
    • Design Lord, Child of Thor

    thanks Joe for your help here.

    I couldn’t get that code to work with the latest version of WordPress, seemed like it was working, but when I made changes to the category ID, it did not reflect those changes in the feed.

    I found some other code, slightly amended to suit my needs and I think it works. Do you see any problems with using the code below?

    /** Remove category from feed and blog page */
    function dtwd_exclude_category($query) {
    if ( $query->is_feed || $query->is_home ) {
    $query->set('category__not_in', '36' );
    }
    return $query;
    }
    add_filter('pre_get_posts', 'dtwd_exclude_category');

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.