How to Disable RSS Feeds in WordPress

WordPress enables RSS and Atom feeds by default. If you do not want your site content or comments to be shared through RSS feeds, you can disable them by adding a few lines to your theme’s functions.php file.

Before You Start

  • Use a child theme if possible. Theme updates can overwrite functions.php.
  • Make a quick backup copy of your current functions.php before editing.
  • You can test feeds using URLs like https://yoursite.com/feed/ and https://yoursite.com/comments/feed/.

Step 1: Locate functions.php

In WordPress, go to Appearance and locate your active theme. The functions.php file is typically found at:

/wp-content/themes/your-theme/functions.php

Option A: Disable All Feed Formats

This disables all WordPress feed endpoints (RSS, RSS2, Atom, RDF, plus comment feeds). When a feed is requested, WordPress returns a clear message and a 410 Gone status code.

/**
 * Disable all feed endpoints (RSS/RSS2/Atom/RDF + comment feeds).
 * Returns 410 Gone to indicate feeds are intentionally unavailable.
 */
function exectech_disable_all_feeds() {
  status_header(410);
  nocache_headers();
  wp_die(
    esc_html__('Feeds are disabled on this site.', 'textdomain'),
    esc_html__('Feed Disabled', 'textdomain'),
    array('response' => 410)
  );
}

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

Step 2: Remove Feed Links from the Site Header

Even after disabling the feed endpoints, WordPress can still output feed discovery links in your HTML header. Add the following to functions.php to remove them:

/**
 * Remove feed discovery links from <head>.
 */
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);

Option B: Disable Only Specific Feeds

If you want to keep certain feeds available, only hook the endpoints you want to block.

Example 1: Disable Only Comment Feeds

function exectech_disable_comment_feeds() {
  status_header(410);
  nocache_headers();
  wp_die(
    esc_html__('Comment feeds are disabled.', 'textdomain'),
    esc_html__('Feed Disabled', 'textdomain'),
    array('response' => 410)
  );
}

add_action('do_feed_rss2_comments', 'exectech_disable_comment_feeds', 1);
add_action('do_feed_atom_comments', 'exectech_disable_comment_feeds', 1);

Example 2: Disable Only the Atom Feed

function exectech_disable_atom_feed() {
  status_header(410);
  nocache_headers();
  wp_die(
    esc_html__('Atom feed is not available.', 'textdomain'),
    esc_html__('Feed Disabled', 'textdomain'),
    array('response' => 410)
  );
}

add_action('do_feed_atom', 'exectech_disable_atom_feed', 1);

Example 3: Allow RSS2, Block Legacy RSS1 and RDF

function exectech_disable_legacy_feeds() {
  status_header(410);
  nocache_headers();
  wp_die(
    esc_html__('This feed format is not supported.', 'textdomain'),
    esc_html__('Feed Disabled', 'textdomain'),
    array('response' => 410)
  );
}

add_action('do_feed_rdf', 'exectech_disable_legacy_feeds', 1);
add_action('do_feed_rss', 'exectech_disable_legacy_feeds', 1);

Quick Validation Checklist

  • Visit /feed/ and confirm you see the disabled message.
  • Visit /comments/feed/ if you disabled comment feeds.
  • View page source on your homepage and confirm there are no rel="alternate" feed links.

Additional Notes

  • If you are using caching or a CDN, purge cache after making changes.
  • If your site uses an SEO plugin, it may add feed-related metadata. The header removal above handles the default WordPress output, but plugins can reintroduce links.

Leave a Reply