Disable or remove RSS Feed in WordPress

How can I remove all RSS feeds?

When WordPress is used as a blog, RSS feeds are a great way (so 80’s) to follow new post.

But when WordPress is used to build a website, maybe you don’t want that people can follow your RSS feeds.

This code to add to your functions.php file don’t remove feeds, but redirect the feeds URL to your home page:

<?php
/**
 * Disable all RSS feeds
 */
function wpster_disable_feed() {
    wp_redirect(home_url('/'));
}
add_action('do_feed', 'wpster_disable_feed', 1);
add_action('do_feed_rdf', 'wpster_disable_feed', 1);
add_action('do_feed_rss', 'wpster_disable_feed', 1);
add_action('do_feed_rss2', 'wpster_disable_feed', 1);
add_action('do_feed_atom', 'wpster_disable_feed', 1);
add_action('do_feed_rss2_comments', 'wpster_disable_feed', 1);
add_action('do_feed_atom_comments', 'wpster_disable_feed', 1);
?>

If you prefer to have a clean code, this one will remove all feeds in 2 steps:

<?php
/**
* Remove all RSS feeds
*/
remove_action('wp_head', 'feed_links', 2 );
add_filter('post_comments_feed_link','wpster_remove_comment_feeds');
function wpster_remove_comment_feeds() {
return null;
}
?>

Submit a Comment

Your email address will not be published. Required fields are marked *