Remove Feeds From Individual Blog Posts in WordPress
WordPress, for whatever reason, automatically creates a feed for every blog post that you create. If you check Google Search Console, you may have noticed that Google can see all of these feeds and they are reporting issues in your dashboard.
You can mostly ignore those errors, since it's basically Google's way of saying "These are RSS feeds, not content pages, so we're not able to index these, just in case you were hoping that we would".
Still, we don't need hundreds of feeds created for our hundreds of content pages, so we should remove this feature. Here's what we can do to fix it; simply add this to your functions.php file in your theme;
/*
* Remove feed from individual blog posts
*/
add_action('template_redirect', 'remove_post_feed_status');
function remove_post_feed_status(){
if (is_singular('post') && is_feed()) {
header('HTTP/1.1 410 Gone');
exit();
}
}
Now, Google will see a "410 Gone" header when visiting these feed pages. This is a much stronger and more purposeful message than "Not Found", which search engines tend to cling to a bit longer in-case it was a mistake or it happens to come back later. A 410 status tells Google that these are gone and never coming back. This way, they won't show up as "404 Errors" in Google Search Console, and these should start to drop off eventually. Though, it may take Google a while to check them again.
Optionally, you can use this version, which redirects the user to the post itself instead of showing a "410 Gone" message:
/*
* Redirect feed requests to individual blog posts
*/
add_action('template_redirect', 'redirect_post_feed_to_post');
function redirect_post_feed_to_post(){
if (is_singular('post') && is_feed()) {
global $wp;
$post_url = get_permalink();
wp_redirect($post_url, 301);
exit();
}
}
With this version, Google Search Console will still report that they couldn't index these because they redirect to a different URL - but it's not a concern.
If the goal is to clean up the messages and warnings in Search Console, I would recommend version #1. If you suspect that real people are visiting your individual /feed/ URLs of each of your blog posts (which I doubt they are, why would they be if they aren't indexed?), then I would recommend option #2.
Personally, I used version #1, but I don't see any issue with using #2, either. They both serve their purpose.
What do you think? Did this help you? Any questions for me? Please let me a comment below and I'll get back to you in 24 hours or less!
March 11, 2024
I already have thousands of postname/feed pages. If I delete them in bulk using this code, will it hurt my Google SEO?
March 28, 2024
Hey there!
No, removing your feeds from individual blog posts won't hurt your SEO in the vast majority of cases.
A feed lists recent articles from a website. So by nature, it doesn't really make sense to have them on each post because that feed won't list anything but that post itself. It doesn't make sense to subscribe to that RSS feed because it will never change.
There is an argument to be made about deleting your main feed (the one at domain . com / feed), but even that is not very likely to hurt your SEO. Still, people may be using it to get notified of your latest posts, so it could cause some butterfly-effect-style indirect harm if whoever was using your feed was about to link to your site and you removing your feed discouraged them from doing that. As you can tell by my joke, this isn't a very likely scenario; maybe for larger publishers where their feed is in use by a larger amount of people.
Removing feeds from your individual posts is fine, though; it won't hurt your relationship with Google or your SEO if done properly.
Great question!
July 09, 2024
Thanks for the code, please where should the code be placed in the php file?
July 09, 2024
Hey Echez! You would paste this at the very bottom of your functions.php file.
Just make sure there isn't a ?> at the very end; this is a closing PHP tag. It's recommended that you don't have one; most properly-built themes don't, but it can't hurt to check yours just incase.