Excluding Categories from Your WordPress RSS Feed

Filed under: Web Development,Wordpress — Tags: , , , — Chris @ 7:45 pm

As a supplement to my previous post about having a separate template for a specific category I thought I should let you know how I excluded a category from a RSS feed.

Say you have a news category that looks different and says something different than the rest of your blog, you might want to exclude that from your RSS feed. I found the following code at WPRecipes (which is down at the time of this writing):

function myFilter($query) {
if ($query->is_feed) {
$query->set('cat','-5'); //Don't forget to change the category ID to what you want
return $query;


Place this in your functions.php file. I’m not sure if you can exclude more than one, but my guess is you can just add more category IDs and seperate them with commas: $query->set(‘cat’,'-5,-10,-11′);