Completely Disable RSS Feeds in WordPress

WordPress generates many kinds of rss feeds automatically,  as demonstrated clearly here , they are:

http://example.com/?feed=rss
http://example.com/?feed=rss2
http://example.com/?feed=rdf
http://example.com/?feed=atom

Most WordPress themes will output them in header area, like:
output rss feeds in header area

on WordPress.com Blog. https://en.blog.wordpress.com/

To make the source code cleaner or for some other purposes, many of us would like to remove them from header, or furthermore, disable RSS Feeds completely. Here are code blocks for you to put into functions.php file under theme folder:

//Disable RSS Feeds functions
add_action('do_feed', array( $this, 'disabler_kill_rss' ), 1);
add_action('do_feed_rdf', array( $this, 'disabler_kill_rss' ), 1);
add_action('do_feed_rss', array( $this, 'disabler_kill_rss' ), 1);
add_action('do_feed_rss2', array( $this, 'disabler_kill_rss' ), 1);
add_action('do_feed_atom', array( $this, 'disabler_kill_rss' ), 1);
if(function_exists('disabler_kill_rss')) {
	function disabler_kill_rss(){
		wp_die( _e("No feeds available.", 'ippy_dis') );
	}
}

//Remove feed link from header
remove_action( 'wp_head', 'feed_links_extra', 3 ); //Extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // General feeds: Post and Comment Feed
This entry was posted in WordPress. Bookmark the permalink.

7 Responses to Completely Disable RSS Feeds in WordPress

  1. Wow.. Thank you so much. I was searching to remove rss feed from last 2 days, finally came here. It worked for me. Thanks a lot.

  2. Sumit says:

    It solved the problem. Thanks

  3. Omkar says:

    Thank you very much.

  4. It worked this time! Thanks for sharing it.

  5. aljuk says:

    Doesn’t work, feeds are still available.

  6. Kar.ma says:

    Thank you very much! I needed this to disable feeds, since I use WordPress as a CMS and I want no blog features.

  7. UnbeatableAnaconda says:

    It may remove a single line from your code, but will break the functionality for users like me, who do like subscribing to WordPress blog feeds for specific categories.

Leave a Reply

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