Do you want to exclude specific categories from the RSS feed of your WordPress blog ? Many site owners use certain categories with a contents that they do not want to appear on their RSS feed.

In this tutorial, we will show you how to exclude specific categories from the RSS feed of WordPress.

category exclusions from the WordPress feed

1 method: exclude specific categories with a plugin

The first thing you need to do is to install and activate the plugin " Ultimate Category Excluder ". For more details, check out our step by step guide on how to install a WordPress plugin.

After activating the plugin, you must visit to access Settings> Category Exclusion », To configure the plugin settings.

ultimate category excluder example settings

The settings page displays all the categories on your WordPress blog with options to hide them from the blog's home page, RSS feeds, archive pages, and search results.

Just select one of the boxes under the column Exclude from feeds », And choose the category you want to hide. Don't forget to save your settings.

From now on, the categories you have selected will not appear in your RSS feed.

2 Method: Manually Exclude Categories from RSS Feed

This method requires you to paste some code into your WordPress files. You can use this method if you are comfortable with editing WordPress code.

You can add this code in the file " functions.php » of your active theme or paste it in your WordPress Plugin (we showed you how to create a WordPress 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 correspond to the given identifiers. Just replace the category IDs in the code with the IDs of the categories you want to exclude.

You will easily find the category IDs by modifying a category. This is usually the number in the browser URL.

Categorie wordpress

If you want to exclude only one category, you can use this code:

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 the category you want to exclude from RSS feed.

That's all for this tutorial, I hope it will allow you to exclude articles from the RSS feed with ease. Do not hesitate to contact us in case of problems.