Exclude Categories from your RSS Feed in WordPress

I had someone ask me how to do this the other day and I didn’t know how. But after reading through some of the WordPress Codex I was able to figure it out. To exclude specific categories from your RSS feed just add the following code snippet to your theme’s functions.php file.
function myFeedExcluder($query) {
 if ($query->is_feed) {
   $query->set('cat','-12');
 }
return $query;
}
add_filter('pre_get_posts','myFeedExcluder');
As always, make sure it is between PHP tags. And if the theme you are using does not have a functions.php file, just create on yourself and add the above code snippet after an opening PHP tag.
Search

Popular Posts

Small Biz Website Tips Newsletter

Stay up to date with the latest marketing, sales, and service tips and news.

Small Biz Website Tips Newsletter

Stay up to date with the latest marketing, sales, and service tips and news.