WordPress

Disable All RSS Feeds On Your WordPress Blog

The thing about wordpress is that it is such a well thought out flexible CMS system that it can be used for any type of website.

For example it can be used for a blog, a journal site, normal website, portfolio, ecommerce, any type of website you want to create can be handled by wordpress as the CMS. I'm not saying it's the best solution for these but it's free and flexible. As this can be used for multiple different types of sites, there is going to be some features which aren't needed or wanted on the other sites.

In this example you will learn how you can disable the wordpress RSS feed. This can be useful for ecommerce sites or for photography portfolio site where you might not want the RSS feed to be available.

To disable the RSS feed you need to use the following hooks and change the functionality.

  • do_feed
  • do_feed_rdf
  • do_feed_rss
  • do_feed_rss2
  • do_feed_atom

In the functions.php page copy and page the following code.

function fb_disable_rss_feed() {
    wp_die( __('Feed is not available please return back to the <a href="'. get_bloginfo('url') .'">homepage</a>!') );
}

add_action('do_feed', 'fb_disable_rss_feed', 1);
add_action('do_feed_rdf', 'fb_disable_rss_feed', 1);
add_action('do_feed_rss', 'fb_disable_rss_feed', 1);
add_action('do_feed_rss2', 'fb_disable_rss_feed', 1);
add_action('do_feed_atom', 'fb_disable_rss_feed', 1);

This code will setup a function which will kill the current operation and return a string which will have a link back to the homepage.

Now you can add the hooks to run this function on any of the RSS feed calls. Now whenever a visitor tries to access the RSS feed the text will be displayed with a link back to the home page.

Back to top ^

Join Paulund

  • Get access to 100s of premium tutorials and downloadable content
  • Members content consists of Premium WordPress plugins, CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
  • In-depth development tutorials
  • Priority tutorial requests
  • Priority email development support
  • No ads

Here at Paulund you'll find Web Development tutorials and snippets focusing mainly on PHP, WordPress and CSS. Members will get access to premium tutorials that go into more detail about development with these languages. You will also get access to downloadable premium content based on the tutorial.

Join Paulund

Leave a Reply

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