Advertisement

Code to Disable Feed URLs on WordPress (Complete Guide for Beginners)

By Abhishek Dey Roy

Updated On:

Follow Us
Code to Disable Feed URLs on WordPress
Advertisement
5/5 - (3 votes)

If you’re looking for a way to disable feed URLs in WordPress, you’re likely concerned about content scraping, duplicate content issues, or you simply don’t use feeds like RSS or Atom on your website. Disabling WordPress feeds can tighten control over your content, improve SEO hygiene, and boost your website’s performance.

In this guide, we’ll walk you through how to disable RSS feed in WordPress using code, following best practices and SEO-friendly strategies.


Why Disable Feed URLs in WordPress?

By default, WordPress automatically generates various feed URLs such as:

These feeds are useful in many cases, but there are valid reasons why you may want to turn them off:

  • 🔒 Prevent Content Scraping – Some bots scrape your content via RSS.
  • 📉 Avoid Duplicate Content – Google may consider feeds as duplicate content.
  • 🧹 Declutter Your Website – If you don’t use feeds, they add unnecessary endpoints.
  • Improve Speed – Fewer endpoints mean less work for your server.

How to Disable Feed URLs in WordPress (Using Code)

How to Disable Feed URLs in WordPress (Using Code)
How to Disable Feed URLs in WordPress (Using Code)

Here’s the recommended WordPress disable feed code snippet that you can safely add to your theme’s functions.php file or a custom plugin.

phpCopyEdit// Disable All WordPress Feeds
function disable_wordpress_feeds() {
    wp_die( __( 'No feed available. Please visit our homepage.', 'textdomain' ) );
}

add_action( 'do_feed', 'disable_wordpress_feeds', 1 );
add_action( 'do_feed_rdf', 'disable_wordpress_feeds', 1 );
add_action( 'do_feed_rss', 'disable_wordpress_feeds', 1 );
add_action( 'do_feed_rss2', 'disable_wordpress_feeds', 1 );
add_action( 'do_feed_atom', 'disable_wordpress_feeds', 1 );
add_action( 'do_feed_rss2_comments', 'disable_wordpress_feeds', 1 );
add_action( 'do_feed_atom_comments', 'disable_wordpress_feeds', 1 );

How It Works:

This code hooks into all WordPress feed actions and replaces them with a simple message or redirect logic, effectively disabling feed URLs.


SEO-Safe Approach (Optional: Redirect Feed URLs)

Instead of showing a message, you can redirect RSS feeds to the homepage to preserve SEO juice and user experience.

phpCopyEditfunction redirect_feeds_to_homepage() {
    wp_redirect( home_url(), 301 );
    exit;
}

add_action( 'do_feed', 'redirect_feeds_to_homepage', 1 );
add_action( 'do_feed_rdf', 'redirect_feeds_to_homepage', 1 );
add_action( 'do_feed_rss', 'redirect_feeds_to_homepage', 1 );
add_action( 'do_feed_rss2', 'redirect_feeds_to_homepage', 1 );
add_action( 'do_feed_atom', 'redirect_feeds_to_homepage', 1 );
add_action( 'do_feed_rss2_comments', 'redirect_feeds_to_homepage', 1 );
add_action( 'do_feed_atom_comments', 'redirect_feeds_to_homepage', 1 );

Best Practices After Disabling Feeds

  1. Test All Feed URLs – Use browser or tools like curl to test /feed URLs.
  2. Update Your XML Sitemap – Make sure your sitemap does not include feed URLs.
  3. Inform Search Engines – Use Google Search Console’s URL Removal Tool if needed.
  4. Check for Broken Links – Use a broken link checker plugin or online tool.

Experience-Based Tips (E-E-A-T Alignment)

Experience-Based Tips (E-E-A-T Alignment)
Experience-Based Tips (E-E-A-T Alignment)

As a WordPress developer managing multiple client websites, I’ve personally encountered cases where RSS feeds led to unexpected traffic dips due to content scrapers. Disabling these feeds helped in:

  • Reducing bot traffic and server load.
  • Improving Google Search Console’s crawl stats.
  • Enhancing overall content security.

By using the above code to disable feed URLs in WordPress without plugins, I’ve helped improve SEO performance for several blogs and corporate websites.


Some FAQs related to Disable Feed URLs In WordPress 

What are WordPress feed URLs?

Feed URLs in WordPress are special URLs that deliver your content in XML format (RSS/Atom), allowing readers and apps to subscribe to updates from your site.

Why would I want to disable feed URLs?

You might want to disable feeds to prevent content scraping, reduce server load, or if you’re running a static or private site that doesn’t need syndication.

How do I check if my feed URLs are active?

Try visiting URLs like yourdomain.com/feed/ or yourdomain.com/?feed=rss2 in your browser. If they show your posts in XML format, feeds are enabled.

Can I disable feeds without a plugin?

Yes, you can disable feeds by adding a simple code snippet to your theme’s functions.php file or via a site-specific plugin.

What is the code to disable all feed URLs in WordPress?

Here’s a commonly used snippet:

function disable_all_feeds() {
wp_die( __( ‘No feed available. Please visit the homepage!’ ) );
}
add_action(‘do_feed’, ‘disable_all_feeds’, 1);
add_action(‘do_feed_rdf’, ‘disable_all_feeds’, 1);
add_action(‘do_feed_rss’, ‘disable_all_feeds’, 1);
add_action(‘do_feed_rss2’, ‘disable_all_feeds’, 1);
add_action(‘do_feed_atom’, ‘disable_all_feeds’, 1);

Will this affect my SEO?

Disabling feeds has a minimal SEO impact, especially if you’re not relying on RSS readers or syndication. However, if you’ve previously submitted your feed to directories or aggregators, you might lose some traffic from those sources.

Conclusion

Disabling feed URLs on WordPress can improve your site’s security, SEO, and user experience especially if you’re not actively using RSS or Atom feeds. Whether you’re running a personal blog or a business website, it’s essential to take control of every URL endpoint your CMS generates.

You can either show a message or redirect visitors it’s entirely up to your site’s needs.

Abhishek Dey Roy

We’re dedicated to providing you the best of Beyond the Niche: A Blog for Every Interest, with a focus on dependability and Blogging, SEO, Digital Marketing, and now Helping Beginners To Build Amazing WordPress Websites At No Cost.