We like to do things without plugin. Specially small tasks like disabling feeds from WordPress. Many sites, specially non-blog sites, would like to disable feeds. With the below code snippet we will disable feed and remove feed links from header, which were generated by default. If anyone tries to access feed urls, they will be redirected to home page instead.
function careless_disable_feeds() {
wp_redirect( home_url() );
exit;
}
add_action( 'do_feed', 'careless_disable_feeds', 0, 1 );
add_action( 'do_feed_rdf', 'careless_disable_feeds', 0, 1 );
add_action( 'do_feed_rss', 'careless_disable_feeds', 0, 1 );
add_action( 'do_feed_rss2', 'careless_disable_feeds', 0, 1 );
add_action( 'do_feed_atom', 'careless_disable_feeds', 0, 1 );
add_action( 'do_feed_rss2_comments', 'careless_disable_feeds', 0, 1 );
add_action( 'do_feed_atom_comments', 'careless_disable_feeds', 0, 1 );
add_action( 'feed_links_show_posts_feed', '__return_false', -1 );
add_action( 'feed_links_show_comments_feed', '__return_false', -1 );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action('wp_head', 'rsd_link');
Code goes in the functions.php
file of your active theme.