Skip to contentSkip to main navigation Skip to footer

How To Remove Category Feed?

Before we get into the solution, it’s important to understand what RSS feeds are and why they matter. RSS stands for “Really Simple Syndication.” It’s a technology that allows people to subscribe to a website’s content, so they can receive updates automatically. When you publish new content on your website, your RSS feed is updated automatically, and your subscribers receive a notification.

WordPress automatically generates RSS feeds for your website, including feeds for your categories. This means that your readers can subscribe to updates for a specific category of content, rather than receiving updates for all of your content. This is a useful feature because it allows readers to stay informed about the topics they care about most.

However, the downside of having category-specific RSS feeds is that Google sees those feeds as separate pages and warn you that the feed pages can’t be indexed.


How do you remove the WordPress feed on categories?

Squirrly SEO has no setting that turns off the WordPress feeds, so the solution is to add some code to your site. Put it in the functions.php file of a child theme, or in a code snippets plugin, so a theme update doesn’t remove it. Here’s the code you need to add:

function sq_no_category_rss_feed()
{
    global $wp;
	$current_url = home_url(add_query_arg(array(), $wp->request));

	if ($current_url <> home_url('feed')) {
		wp_redirect(home_url() . str_replace('/feed','',$_SERVER['REQUEST_URI']));
		exit();
	}

    return true;
}

add_action('do_feed', 'sq_no_category_rss_feed', 1);
add_action('do_feed_rdf', 'sq_no_category_rss_feed', 1);
add_action('do_feed_rss', 'sq_no_category_rss_feed', 1);
add_action('do_feed_rss2', 'sq_no_category_rss_feed', 1);
add_action('do_feed_atom', 'sq_no_category_rss_feed', 1);

This code creates a function called sq_no_category_rss_feed that runs when WordPress is about to show a feed (RDF, RSS, RSS2 or Atom). It compares the address with your main feed, /feed/. For any other feed, the function redirects the visitor to the same URL without the “/feed”. This removes the feed on categories and avoids the issue of Google Search Console showing these URLs as not indexed.

The code does more than remove the category feeds. It redirects every feed except the main /feed/ of the site: category and tag feeds, author feeds, custom post type feeds, the feed of each post’s comments and the comments feed of the whole site. For example, /category/news/feed/ goes to /category/news/. The redirect is temporary (HTTP 302), because wp_redirect() uses 302 when no status is given.

Once you have added this code to the functions.php file of your child theme, save the file and upload it back to your WordPress installation (in a code snippets plugin, save and activate the snippet). You should now be able to check your site in Google Search Console and see that the feed URLs on categories are no longer showing up as not indexed.

Removing the WordPress feed on categories is not ideal for all websites. If your site has a lot of content, and you cover a wide range of topics, then having category-specific RSS feeds can be very useful for your readers. In this case, you may want to leave the feeds as they are.

To keep your category URLs short as well, see No Category Base.

Before you leave

Future of AEO GEO and AI Search!

Free Now. Free Forever.

It’s time to stop orbiting SaaS.

Be the Meteor.

10 Elite Tools. 1 Stack.