How to Disable WordPress RSS and Comments Feed

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);
?>

2 thoughts on “How to Disable WordPress RSS and Comments Feed

Leave a Reply

Your email address will not be published.

Are you in need of a freelance web developer?

Hire me