wordpress snippets last updated   : October 6, 2014
we now have 641 snippets

Exclude categories from RSS feed with functions.php

wordpress snippet

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

snippet :  PHPcopy
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');

Did you like this post? If so please share it with your friends. Thanks!

  • Zachary Levine

    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.

    • http://wpsnipp.com Kevin Chard

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

  • SY

    thank

jqsnipp.com | we just launched jquery snippets website