WordPress Disable RSS Feed

Explains how to disable Wordpress RSS / Atom / RSS2 feed url in 2 simple steps.

Some webmasters and small business owners use WordPress as CMS. They may not need any sort of RSS feed. This is also good for security and private space blogs. You can easily disable all RSS feed by editing functions.php file. This file used to change the default behaviors of WordPress. It goes in your Theme’s folder. A Child Theme can have its own functions.php.

The functions file behaves like a WordPress Plugin, adding features and functionality to a WordPress site. You can use it to call functions, both PHP and built-in WordPress, and to define your own functions. You can produce the same results by adding code to a WordPress Plugin or through the WordPress Theme functions file.

How do I edit functions.php?

Click on Appearance > Themes > Theme Editor > Locate and edit your functions.php. Beware: if you do not edit file properly the results can be unexpected — even site-disabling. Make a backup of your exisiting file using ftp / sftp.

Fig.01: WordPress Themes Editor
Fig.01: WordPress Themes Editor

Make sure you add the following code between <?php ?> tags.

/**
 * Disable Our Feed Urls
 */
function disable_our_feeds() {
	wp_die( __('<strong>Error:</strong> No RSS Feed Available, Please visit our <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);

Save and close the file.

Author: admin

I like chocolate, gadgets, open source software, photography, traveling and all shades of green colors. I love spending time with fun loving friends and family members. This is my own online journal.

27 thoughts on “WordPress Disable RSS Feed”

  1. Pingback: News Roundup: Dec., 15, 2008 | Linux Plus
  2. Try this:

    create a directory called “feed” in your wordpress root and upload a blank index page (e.g. index.html or index.php etc.). RSS links from WP will display a wonderful white page instead of rss file.

  3. Instead of the wp_die, I use wp_redirect(get_option(‘siteurl’)); which just sends them back to the homepage. I also disable rss from the head by removing it from the template altogether. Combined these remove the icon and the actual feed url from working at all.

  4. Any idea how this can be used to OVERWRITE the template being used e.g. for RSS2? I don’t want to change the core files, but it seems like there is no other way…

  5. We find another way:
    insert into .htaccess before wordpress rewrite rule
    2 line:
    RewriteRule feed – [G,L]
    ErrorDocument 410 /410.html

    and adding in root dirrectory (where wp-config.php) file 410.html with your content.
    Thats all. Fully working mechanism.
    Warning – Working only with pretty permalink!!!

  6. HELP!! I embedded this code and now i only get a bunch of errors and cannot get back to my edit page on wordpress???

  7. Ugh! I tried this and all it did was add a bunch of jibberish text at the top of my page where the normal WordPress header goes and it didn’t remove the RSS feed logo, which is all I wanted to do because I don’t need that. Admittedly, I’m a graphic designer, not a programmer. I can always have my web guy edit it because he has admin access …but it’d be easier if I just knew how it worked :) Thanks!

  8. Tnx dude, this worked perfect.

    You have to put the code before the function get_feed from the top. Save the file like that and add it back on your server. You can add what message you want to show like a “error” ! :)

  9. Just one question:
    Even if you’re a webmaster of a small site or use wordpress as a CMS. Why the h* would you want to disable your rss-feed? It allows easily staying in touch with your site/news. If you want your readers to go to your page, use excerpts (the more-tag).

    Also, most of the proposed workarounds are probably lost after an upgrade. And you really do need wordpress-updates eg. because of security issues.

    Better use a plugin which handles this: https://wordpress.org/extend/plugins/search.php?q=disable+rss+feed&sort=
    Still, I see no reasonable reason to do so.

  10. /**
     * Disable Our Feed Urls
     */
    function disable_our_feeds() {
    	 wp_redirect(get_option(‘siteurl’));
    }
    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);
    
  11. “/feed/rss will still work”

    That is NOT true, if you do it good, none of your feeds will work!
    So yes the script works

  12. Hello, first of all thanks for the solution, it worked great for me!

    To those who didn’t manage to use the procedure (WordPress got messed up with code after modifying functions.php), make sure you put the code into tags, else it won’t be recognized as php code, therefore shown on screen as text. It also happened to me firstly :-)

Leave a Reply

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