07Jul2009

Disabling RSS Feeds in WordPress

Disabling RSS in WordPress

Sometimes, if you’re using WordPress as a content management system (CMS), you don’t want to enable RSS feeds. For example, if you’re running a corporate website, an informational site, or any other kind of website that doesn’t need to have RSS, then its worth disabling RSS on your WordPress site. After some digging around, I’ve found some tricks that allow you to disable RSS feeds.

I haven’t yet found a (non hacky) way to remove the RSS entry in the <head> tags, but when I do, I’ll update this article.

Updating your template functions.php

In your template code, if you copy and paste the following code into the functions.php file, users will get a message saying that RSS feeds have been removed.

1
2
3
4
5
6
7
8
9
10
function disable_our_feeds() {
   wp_die( __('<strong>Error:</strong> No RSS Feed Available,
   Please visit our &lt;a href="'. get_bloginfo('url') .'">homepage</a>.') );
}
 
add_action('do_feed', 'disable_our_feeds', 1);
add_action('do_feed_rdf', 'disable_our_feeds', 1);
add_action('do_feed_rss', 'disable_our_feeds', 1);
add_action('do_feed_rss2', 'disable_our_feeds', 1);
add_action('do_feed_atom', 'disable_our_feeds', 1);

Updating .htaccess

To stop users reaching the RSS page in the first place, you can redirect domain.com/feed back to domain.com using your apache .htaccess file.

1
2
3
4
5
6
# Remove RSS feed
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule feed(.*) http://www.yourwebsite.co.uk/ [L]
</ifModule>

Doing it with a plugin

The code changes above should only be done if you know what you’re doing. If you still want to disable RSS feeds, but you’re not that comfortable editing code, then I suggest using the Disable RSS plugin to do it.

Author
Dan Harrison

About the Author

Dan has been creating websites since 2003, and is 100% self-taught. Through lots of trial and error, Dan has learnt how to create successful websites, sharing his knowledge on RunningAWebsite.com. Dan is also a highly experienced Wordpress Developer, offering bespoke Wordpress development services in addition to his free Wordpress plugins.

Dan Harrison has written 38 articles on Running A Website.

Sharing is caring.
  • Subscribe to our feed
  • Share this post on Delicious
  • StumbleUpon this post
  • Share this post on Digg
  • Tweet about this post
  • Share this post on Mixx
  • Share this post on Technorati
  • Share this post on Facebook
  • Share this post on NewsVine
  • Share this post on Reddit
  • Share this post on Google
  • Share this post on LinkedIn

Discussion

6 responses to "Disabling RSS Feeds in WordPress"

  • I’ve not had a need for this yet, though for some people I would think it could be quite useful.

    It may be worth submitting this to WPRecipes.com (http://www.wprecipes.com/contribute) they have over 4100 RSS subscribers and may bring you some traffic.

  • Dan Harrison says:

    Thanks for the tip Darren, that’s a great WP site to read!

  • Hi Dan,

    now that is a great tip but I can’t see why even corporate websites wouldn’t want to have RSS. I mean even larger websites can benefit from using RSS so don’t you find that it would be more valuable to fit RSS into the strategy instead of just removing it?

  • Dan Harrison says:

    Generally, RSS is useful. However, sometimes I just don’t want the hassle of setting up a RSS feed… especially for a mini site.

    Dan

  • Dana says:

    I am tired of people scraping my feed and coming up in search engines before me for content I wrote.

    I am glad I found this option.

    I noticed one draw back though- my content no longer shows up in Google’s blog search.

  • Dan Harrison says:

    Hi Dana,

    If your content is getting scraped, I suggest using the wordpress plugin WP Footer by Yoast, which means you can at least get a backlink to your website. It’s worth being in the blog search for the extra traffic.

    Dan

Leave a Comment