X

Exclude categories from RSS feed with functions.php

Adding this snippet to the functions.php of your wordpress theme will exclude specified categories from RSS feed.



Code Snippet:


function exclude_cat_wps($query) {
if ($query->is_feed) {
$query->set('cat','-20,-21,-22′);
}
return $query;
}
add_filter('pre_get_posts','exclude_cat_wps');

Comments  Leave a Reply

  1. thank

  2. Does this take some time to update? I followed these instructions exactly but the category’s posts are still showing up in the RSS2.0 feed.

    1. Hi Zachary
      No this should work right away, do you have any other code that may cause this to have problems? RSS related plugins,

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!