Exclude Categories from WordPress Feed

Want to keep posts from a given WordPress category or categories out of your public feed?  If so, just edit the template’s functions.php file and append this code…

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

add_filter('pre_get_posts','myFeedExcluder');

This code will keep the category ID=”12″ out of the feed. If you want to exclude more than one category, put them in separated by commas ‘-12,-25,-33′.

Thanks to this page for this tip!

Leave a Reply