How to disable the RSS feed on a WordPress site

WordPress was originally built to be a blogging platform, but in recent years, it has evolved far beyond that.  Today, WordPress is used for all sorts of websites, from traditional blogs, to enterprise websites, to business card websites for mom and pop shops.

While bloggers like myself appreciate all that WordPress can do, the truth is, most websites don’t need a lot of  the out of the box functionality to be enabled. For example, when I build a business card website for a small business, one of the first things I do is disable the RSS feed. They just won’t get any benefit out of it on their site.

Why get rid of the feed?

RSS is great for syndicating content, but if you have a business card website or don’t regularly publish content that people would want to subscribe to, all it’s really doing for you is making your content easier for other people to take and re-purpose on their own sites (there are even WordPress plugins that make it crazy easy for people to do this). This can result in a lot of crappy links, and even some duplicate content issues in some cases.

When you have a blog, it’s well worth the risk to keep the RSS feed running. But in some cases, there’s just no benefit.

How to get rid of the feed

Disabling the RSS feed is simple, though you will need to be comfortable editing functions.php (remember to make a backup before you start).

Step 1: Open your functions.php file in your favorite text editor. Make a backup, and then scroll to the bottom of the file. Copy and paste this code into functions.php. This code will replace the contents of your RSS feed with a simple message that directs visitors to your homepage:

function disable_feed() {
wp_die( __('Our RSS feed is disabled. Please <a href="/">visit our homepage</a>.') );
}

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

Step 2: Save functions.php. Load yoursite.com/feed in your browser, and you should see the new error message.

Step 3: Your feed is now disabled, which is a good first step. But there is one more thing that we still need to do. If you view the source of your website, you will see two references to yoursite.com/feed in the head section of your site. Since your feed isn’t functional anymore, let’s go ahead and remove those references.

With functions.php still open, copy and paste the following code:

function removeHeadLinks() {
      remove_action( ‘wp_head’, ‘feed_links_extra’, 3 );
      remove_action( ‘wp_head’, ‘feed_links’, 2 );
      remove_action( ‘wp_head’, ‘rsd_link’ );
}
add_action('init', 'removeHeadLinks');

Now view your page source again, and the references to your RSS feed should be gone.

Congratulations! You’ve successfully disabled your site’s RSS feed.

a picture of kevin spence.by: Kevin Spence

Kevin Spence built his first website in 1999. These days, he builds all of his sites on WordPress using the Genesis Framework, and manages them using these tools. Follow him on Twitter.

Get Email Updates

Sign up to receive email updates each time we publish a new SEO or WordPress tip (normally 2-3 times a week).


Comments

  1. Hey Kevin,

    Great tutorial. I’ve implemented the code on one of my new websites. Only issue I had was the removal of the reference to the feed in the header section. The code didn’t work for me. I tried this instead and it work for me.

    remove_action( ‘wp_head’, ‘feed_links_extra’, 3 );
    remove_action( ‘wp_head’, ‘feed_links’, 2 );
    remove_action( ‘wp_head’, ‘rsd_link’ );

    I found the above code here: http://wordpress.org/support/topic/remove-feed-from-wp_head It’s the code posted by hollywoodgrind.

    -rick

Speak Your Mind

*