Easy Guide to Exclude Specific Categories from WordPress RSS Feed

In this tutorial, we will learn how to exclude specific categories from WordPress RSS feed.

Method 1: Exclude Specific Categories from WordPress RSS Feed Using Plugin

01: First thing you need to do is install and activate the Ultimate Category Excluder plugin. For more details, see our step by step guide on how to install a WordPress plugin.

02: Upon activation you need to visit Settings » Category Exclusion to configure plugin settings.

Exclude Specific Categories from wordpress rss

03:The settings page will display all categories on your WordPress blog with options to hide them from front page, RSS feeds, archive pages, and search results.

04:Simply select the exclude from feed box next to the categories that you want to exclude from your RSS feed.

05: Don’t forget to click on update button to save your settings.

That’s all, posts filed under your selected categories will disappear from your WordPress RSS feed.

Method 2: Manually Exclude Specific Categories from WordPress RSS Feed

This method requires you to paste code in your WordPress files. You can use this method if you are comfortable with pasting code snippets from web into WordPress.

You need to add this code to your theme’s functions.php file or a site-specific plugin.

function exclude_category($query) {
    if ( $query->is_feed ) {
        $query->set('cat', '-5, -2, -3');
    }
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

This code simply excludes categories that match the given IDs. Simply replace the category IDs in the code with the IDs of categories that you want to exclude.

See our guide on how to find category IDs in WordPress.

If you just want to exclude a single category, then change the code like this:

function exclude_category($query) {
    if ( $query->is_feed ) {
        $query->set('cat', '-15');
    }
return $query;
}
add_filter('pre_get_posts', 'exclude_category');

Replace -15 with the ID of category that you want to exclude from RSS feed.

We hope this tutorial helped you learn how to exclude specific categories from WordPress RSS feed.