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.

Share this:

Email
Facebook
Twitter
Pinterest
Pocket

Premium Themes for WordPress

Looking for an easy-to-use Premium Theme for WordPress? Check out Themes by bavotasan.com and have your site up and running in no time.

Use this WordPress website builder to build powerful websites in no time for your or your clients.

WordPress Hosting

WP Engine – designed from the ground-up to support and enhance the workflow of web designers.

Bluehost – providing quality web hosting solutions since 1996.

About the author

Picture of Luke Perrie

Luke Perrie