How to Exclude a Category from your Blog Feed
The are many reasons why you may want to exclude a specific blog category from your RSS feed. The most often excluded blog category for us is testimonials, which is often pulled to use as rotation text somewhere on a website.
Setting your client testimonials up as a blog category makes it easy to add and mange them but excluding them from your blog feed takes a little effort, but not much.
All you need to do is add a few lines of code to the functions.php file in your theme:
function exclude($query) {
if ($query->is_feed) {
$query->set('exclude','-19');
}
return $query;
}
add_filter('pre_get_posts','exclude');
In the code above simply replace the category ID number with the category ID on your blog that you want to exclude.
If you don’t have a functions.php file in your theme, you can create a new file in Notepad, just type <?php the above code and ?> after the code, then save and upload to your theme’s folder.
And that’s it.