How to Disable RSS Feeds in WordPress

WordPress is widely recognized for its robust blogging capabilities, and a key feature supporting this is RSS Feeds.
These feeds allow users to subscribe to new content you post and integrate with third-party reader applications like Feedly, enabling them to consume your content conveniently on the go.
However, not every WordPress user leverages its blogging features. Some businesses might even prefer to disable RSS feeds in WordPress, reducing one less aspect to manage.
Out of the box, WordPress automatically creates a variety of RSS feeds, including:
http://example.com/feed/
http://example.com/feed/rss/
http://example.com/feed/rss2/
http://example.com/feed/rdf/
http://example.com/feed/atom/
These feeds are not just limited to your main content but also extend to categories, tags, comments, and more.
WordPress Disable RSS Feed Using Custom Code Snippet
To disable a WordPress RSS feed, another effective method is to directly modify the code.
As a precaution, ensure you have a recent backup of your site. Additionally, implement these changes in a WordPress child theme to preserve your modifications during any future theme updates.
Once these steps are in place, insert the following code into your child theme’s functions.php file:
/**
* Display a custom message instead of the RSS Feeds.
*
* @return void
*/
function wpcode_snippet_disable_feed() {
wp_die(
sprintf(
// Translators: Placeholders for the homepage link.
esc_html__( 'No feed available, please visit our %1$shomepage%2$s!' ),
' <a href="' . esc_url( home_url( '/' ) ) . '">',
'</a>'
)
);
}
// Replace all feeds with the message above.
add_action( 'do_feed_rdf', 'wpcode_snippet_disable_feed', 1 );
add_action( 'do_feed_rss', 'wpcode_snippet_disable_feed', 1 );
add_action( 'do_feed_rss2', 'wpcode_snippet_disable_feed', 1 );
add_action( 'do_feed_atom', 'wpcode_snippet_disable_feed', 1 );
add_action( 'do_feed_rss2_comments', 'wpcode_snippet_disable_feed', 1 );
add_action( 'do_feed_atom_comments', 'wpcode_snippet_disable_feed', 1 );
// Remove links to feed from the header.
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
After that, if someone visits an RSS feed on your site, they will see the following message:
No feed available, please visit our homepage!
And that’s it! That’s how you can disable RSS Feeds in WordPress.