How To Easily Remove WordPress Categories From The RSS

Every website built on the WordPress content management system also has its RSS feed. This allows users to add your site to their RSS readers and stay informed about every new article you publish. It’s definitely a great thing, especially for your regular readers. However, sometimes there are categories that you don’t want to include in this RSS feed. That’s why in this article, we’ll explore how to remove specific WordPress categories from the RSS feed. We’ll do this using a short PHP code and the WPCode plugin.

How To Easily Remove WordPress Categories From The RSS

What is an RSS Feed?

Within WordPress, an RSS feed represents a form of content distribution. It enables users to receive updates from your website without the need for manual visits. This tool operates on the principle of syndication, gathering information about new articles, updates, or changes on your website and providing them in a structured format that’s easily readable by various RSS readers.

An RSS reader is software that functions similarly to an email client. It checks a page, reads its new content, and presents it to you. Then, you decide whether you want to view that content and visit the page or not. This is practical when you’re following, for example, 10 favorite websites. You don’t want to visit ten websites every day to check for new articles. The RSS reader does this for you, conveniently fetching and displaying all the articles.

How to Find a Category ID

Every post, page, category, or tag in WordPress has its unique ID. This ID is typically useful for website modifications or when inserting new functionalities into the site through shortcodes. Simply put, if you intend to affect only specific categories using a shortcode or snippet, you’ll need to know their IDs.

Finding the ID of a category is quite simple. When you click on a particular category in the WordPress admin area, you can see its ID directly in the URL address. That’s perhaps the quickest way to find an ID.

Jak odstranit určité kategorie WordPressu z RSS feedu

If you’re interested in a complete guide on finding the ID numbers of categories or even tags, check out this article where the entire topic is discussed in more detail: How to Find the ID of a Post, Page, Category, or Tag in WordPress?

How To Easily Remove WordPress Categories From The RSS using WPCode plugin

To avoid installing an additional plugin for these purposes, we’ll use a snippet and the popular WPCode plugin, which should be installed by anyone looking to customize their WordPress website’s properties and behaviors. A snippet is nothing more than a short piece of code in PHP or another language that alters the properties and behavior of the website.

Installing the WPCode plugin

To insert codes into your website, you have two options. You can hardcode the code into the file where it belongs, or you can use a plugin that dynamically inserts portions of the code into the website during its operation. The second option is better for one simple reason: it’s safer, and your code won’t be erased with each update that overwrites the file containing your code.

Here are the steps to install the WPCode plugin:

  • Click on ‘Plugins‘ in the left menu.
  • Choose ‘Add New‘ in the submenu.
  • Notice the search field in the top right corner.
  • Type in the key phrase ‘WPCode‘.
  • Once WordPress finds the plugin, install and activate it.

If you’re interested in a complete article where I describe working with this plugin, check it out here: How to insert custom codes into WordPress.

Jak do WordPressu vkládat vlastní kódy

Snippet to Exclude a Category from the RSS Feed

Using the WPCode plugin, insert this snippet into your website:

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

Pay particular attention to the line:

					$query->set('cat', '-5, -2, -3')

This line defines the IDs of categories you want to remove from the RSS feed. This brings us back to the beginning of the article, emphasizing the importance of first discovering these IDs. Once you know them, simply adjust the numbers in this snippet according to the IDs of your categories. The code might look something like this:

					function exclude_category($query) {
    if ( $query->is_feed ) {
        $query->set('cat', '-12, -8, -19');
return $query;
add_filter('pre_get_posts', 'exclude_category');

How To Easily Remove WordPress Categories From The RSS


Once you’ve inserted this snippet into your website, save it, and don’t forget to activate it as well. If the plugin is active, it will exclude from your RSS Feed the specific categories you don’t want there for any reason.

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.


Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Upozornit na
0 Komentáře/ů
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje