Posts Tagged ‘atom’

Disable RSS feeds for your website

Sunday, June 1st, 2008

WordPress comes out of the box with RSS functionality. Great if you need it, but it lacks an easy off-switch if you don’t. A rare oversight, let’s fix it!

Disable feed creation

WordPress actually supports a number of different feed layouts, controlled by the actions do_feed_rdf, do_feed_rss, do_feed_rss2 & do_feed_atom. These actions can be removed, the easiest way to do this is by adding the following lines to the functions.php file of your theme. It can also be done by writing a new plugin, my preferred method because if I switch to another theme I might forget to move over these changes.

1
2
3
4
remove_action('do_feed_rdf', 'do_feed_rdf', 10, 1);
remove_action('do_feed_rss', 'do_feed_rss', 10, 1);
remove_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
remove_action('do_feed_atom', 'do_feed_atom', 10, 1);

This disables WordPress’s ability to fill the feeds with posts when requested: feeds will be empty and/or return an error.

Disable feed access

We can improve on this slightly by making an optional change in wp-blog-header.php. It is up to you whether you do this or not: it is a core file, so whenever you upgrade WordPress you will have to redo this.

In wp-blog-header.php find:

1
wp();

Add the following lines below:

1
2
3
if (is_feed()) {
   die();
}

Now whenever someone tries to access your feed directly, nothing happens. No error, no nothing. Nothing to see here, move along…

Disable feed notification

Modern browsers like FireFox & Internet Explorer 7 display the feed notification icon in the address bar when a feed was found for the website you are viewing:

It does not make sense to notify visitors of a non-existing feed.

In the header.php file that belongs to your current theme, find and remove the following line:

1
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />

Depending on the theme you are using, there might be additional links to the feed build in. If you use the standard WordPress theme, you should edit the footer.php file.

That’s it, RSS feeds have now been completely disabled on your website. Make sure your clear your browser cache or it might not appear to work.

Downloads

For your convenience, here is a very simply plugin that will disable feed creation. Just put it in your wp-content/plugins directory and active the plugin.

Feed Disabler Plugin