WordPress – How to disable RSS feeds

The following code can be added to your theme’s functions.php file to disable the RSS feed on the home page and on each article page.

If someone tries to access your RSS feed they will see a message which reads:

No feed available, please visit the homepage


If a search engine spider tries to access the RSS feed it will receive a 410 code which instructs –

410 Gone: the resource requested is no longer available and will not be available again.

The code needs to be added after the  <?php

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

You may also be interested in: WordPress - How to remove RSS Feed URL's from page head.

Tagged in

Leave a Comment

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