Here is a great alternative for disabling the WordPress RSS and comments feeds that doesn’t require hacking any of the core WordPress files.
In using WordPress as a CMS, you may come across a situation where the RSS and comments feeds are unnecessary. To completely disable the feeds requires hacking the core WordPress files, which is something I simply refuse to do. Instead, we can use a clever little function to deny access to the feeds and hide them from the user.
All you need to do is add the following function to your functions.php file:
<?php
function disable_feed() {
wp_die( __('Sorry, there is no feed available. Please visit our <a href="'. get_bloginfo('url') .'">homepage</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);
?>
This formal post helped me very much! Saved your blog, extremely interesting categories just about everywhere that I see here! I appreciate the information, thank you.
Thank you for that function.
How can I modify it to disable only comments feed and retain posts feed (WordPress RSS)?