How to disable WordPress feeds

A simple code snippet for your (child-)themes functions.php to disable various feeds:

function tk_disable_feed() {
  wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
}
     
add_action('do_feed', 'tk_disable_feed', 1);
add_action('do_feed_rdf', 'tk_disable_feed', 1);
add_action('do_feed_rss', 'tk_disable_feed', 1);
add_action('do_feed_rss2', 'tk_disable_feed', 1);
add_action('do_feed_atom', 'tk_disable_feed', 1);
add_action('do_feed_rss2_comments', 'tk_disable_feed', 1);
add_action('do_feed_atom_comments', 'tk_disable_feed', 1);

 

Leave a Comment

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