Exclude Category from the Feed doesn’t work in WordPress

WordPress version: 3.1

I need to exclude one category from Feed, so I add the following function to the functions.php file. However, it doesn’t work. How to fix it?

function ExcludeCategory($query) {
    if ($query->is_feed) {
        $query->set('cat','-1716');
    }
    return $query;
}
add_filter('pre_get_posts','ExcludeCategory');

Related posts

Leave a Reply

3 comments

  1. I am not sure if you are referring to the blog home page. If that’s the case then you probably need to replace ‘feed’ with ‘home’. Otherwise, the code seems fine.