How to Disable RSS Feeds and RSS Feed Links in WordPress

Manuel campos

To disable RSS feeds in WordPress using the functions.php file, you can use the following code:

function disable_feed() {
 wp_die( __( 'This site does not have a feed, visit the <a href="'. esc_url( home_url( '/' ) ) .'">home page</a>!' ) );
}
add_action('do_feed', 'disable_feed', 1);
add_action('do_feed_rdf', 'disable_feed', 1);
add_action('do_feed_rss', 'disable_feed', 1);
add_action('do_feed_rss2', 'disable_feed', 1);
add_action('do_feed_atom', 'disable_feed', 1);
add_action('do_feed_rss2_comments', 'disable_feed', 1);
add_action('do_feed_atom_comments', 'disable_feed', 1);

This additional code will prevent the link from showing on your source code:

remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );

Once you have added the code to the functions.php with the help of your child theme, custom plugin, or a code snippet plugin, the feeds for your WordPress site will be disabled and the feed link will be removed.

Table of Contents

Additional Resources

Wanna buy me a Coffee?
JM
About me
I am José Manuel. I am writing about things I know and things that I am learning about WordPress. I hope you find the content of this blog useful.
Linktree
Care for Site Speed?
I think you can’t go wrong with Cloudways, CloudFlare, and Perfmatters.
Perfmatters Cloudways

WPSurfer.com

Resources to host, secure, speed up, rank, and monetize your WordPress sites.
Plugins
Services
Connect
LinkedIn
Facebook
LinkTree