WPSurfer.com

How to Disable RSS Feeds and RSS Feed Links in WordPress

Published on September 24, 2022 | Updated on June 19, 2023

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.

Additional Resources

Manuel Campos

Manuel Campos

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.

WP SURFER

home

about

privacy

contact

© 2024 WP SURFER • Made with Love in Costa Rica