Disable WordPress Feed

A really good feature for many websites and already a standard on many blogs is the possibility to subscribe via feed for new posts.

But if you use WordPress for a specific purpose, for example as a CMS, it's possible that you really don't need that feature because it has no extra value for your users. Maybe because you only have static pages or you just don't want to spread your news this way.

For everybody who doesn't need the feed functionality in WordPress I show you in a little tutorial how to deactivate all formats of a feed in WordPress.

The easiest way, which I personally don't recommend, is to adjust your code in the core files. You can find the responsible code in wp-settings.php, in your root of WordPress.

require (ABSPATH . WPINC . '/feed.php');

With this method you have an easy way to deactivate, but you have to do it again when the next update for WordPress is knocking on your door. That can be a torture, especially when the automatic update is coming along with WordPress 2.7 - How core update in WordPress 2.7 works.

A little bit more time consuming method is to deactivate feeds via hook in your theme or a Plugin. You just have to copy the following lines and copy them into functions.php of your theme. If this file doesn't exist, just create it and WordPress will recognize it.
The feed is not deleted, but the user gets an info. In detail, the feed URL will still exist, but if the user put in the URL directly, he doesn't get any content but a text, which is been placed in the following code.

/**
 * disable feed
 */
function fb_disable_feed() {
	wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
}

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

That's an easy way to disable feeds on your website.
I do adjustments like this also for my clients in the backend. I only show my clients what they really need to see. Functions, which he doesn't need for his use are hidden - easily possible with my Plugin Adminimize. More about Adminimize in a future post.

Comments are closed.

38 comments

  1. SE7EN

    I deleted/renamed php files relate to feed

  2. Dave

    Hey!

    Im a total noob with this, so Im kinda confused. Im using the Sharpfolio theme. Ive tried to paste the code into functions.php but I only get some weird error message. Am I supposed to paste this after the codes thats already there or before? What EXACTLY should I do? I really appreciate all the help I can get!
    Thanks

  3. Michael

    Dave, do you have php start and end tags?

    < ?php
    //the complete code
    ?>

  4. Dave

    Thanks for the tip Michael, but Im afraid I screwed up big time.

    I tried what you wrote, but it didnt work. probably me doing something wrong.
    Then I tried something on my own and ended the code with instead. Now I cant login to my page anymore. I just get a white blank page. What do I do?!?!?!

  5. Michael

    Dave, mail the file you have changed to info at wpengineer dot com.

  6. Dave

    How do I do that? I cant access the dashboard.
    A friend of mine is the one who installed WP, so its not installed on MY computer. Do I need to ask him?
    Thanks so much for the help Michael!

  7. Michael

    Yes, ask him for help.

  8. Michael

    Hi Michael! Great name.

    Listen, I am using this to disable feeds, but I am hoping there is a way to only disable the MAIN Entries feed...

    I'd still like to have feeds available for each category... please help if you can!

    Thanks

    - Michael

    P.S. Basically... what I'm trying to do is use Feedburner to create a feed for just two of my categories, but I don't want to have both categories showing up in ONE rss feed... so I do need to disable the main feed.

  9. Cheryl F. (The Lucky Ladybug)

    This works fine for template-added RSS links which I'll be removing anyways and also if I copy and paste or type the feed address in the address bar. It doesn't seem to work for Firefox's auto-feed discovery in the address bar and at the top right of each page. When I click on either of those I'm taken directly to my feed in my feedreader with all posts showing. Is there any way around this?

  10. Sushant

    Thank you for the tip. It worked perfectly for me. However is there any way to change the title. WordPress shows in the title "Wordpress -> Error" .

  11. Dennis

    Hi, /feed/rss still works after this change.

  12. Hansi

    da war jemand genauso "schlau" wie ihr: wpcanada.ca/2009/12/22/how-to-disable-your-rss-feed/

  13. Michael

    Hansi, die haben nur geklaut. Du siehst es an der Funktion fb_disable_feed(). fb steht für Frank Bültge.

  14. Ventura County Web Design

    Yeah this does not work. It just creates a PHP error. Oh well.

  15. Frank

    @Sushant: yes you can add a second parameter to function wp_die(); example:

    function fb_disable_feed() {
    wp_die( __('No feed available,please visit our homepage!'), 'My Title' );
    }

  16. Frank

    @Dennis: i had tested this on different pattforms, works fine, on all feeds, also /feed/rss
    The hook do_feed_rss is for this feed on format rss 0.91

    @Ventura County Web Design: please copy the code; works fine and have no erros: Copy in the functions.php of your active theme.

  17. Frank

    @Cheryl F. (The Lucky Ladybug): PLease see in your functions.php, search the function automatic_feed_links(); and killl them.
    I think this is enough; aditiona you can add the follow actions in the function.php of your Theme.

    remove_action( 'wp_head', 'feed_links_extra', 3 );
    remove_action( 'wp_head', 'feed_links', 2 );
    remove_action( 'wp_head', 'rsd_link' );

  18. Theo

    Danke für den Skript !
    Gibt es eine Möglichkeit, oder wie kann ich dieses Skript nur für statische Seiten innerhalb eines Blogs verwenden ?

    Gruß Theo.

  19. Brokenjava

    It was another tips, just create new file/folder called "feed" on our public_html. WordPress feed will not working anymore..

  20. Frank

    @Theo: The pages from WP has not a feed; you must add a plugin for this feature. Please see on the official WordPress Site for a plugin for this solution.

  21. Leshia

    Hi!

    Thanks for the code but it returns a 500 - server error. Since the RSS feed link automatically shows up in the header of each page, it is generating quite a few 500's. How do I fix this?

  22. Alex

    Thanks for sharing this wonderful tip!

    Do you know how do I turn off comments feed only? Thanks.

  23. Lee

    This blocks my rss feeds.
    I dont want it to.
    How can I edit this so that I can still access the feed via the standard urls?

  24. Basti

    Hi,

    thanks for the tip! It's pretty close to what I did, the difference was that I did a redirect to the homepage. Your solution is better because the visitor will get a feedback.

    Just one issue to make it perfect: Any idea how to remove that rss-icon in the browser (adress bar) - this one indicates that a webpage has actually got a feed... It's just cosmetic, but the visitor could get confused by this.

    Best regards and thanks, thanks, thanks for sharing all that great stuff.

  25. Basti

    Yeah, I just found it:

    You have to clear the line in your theme's header:

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

    (just for the case the code above won't get formatted right: there should be a "link" tag with "href" = bloginfo('rss2_url') or sth similar.)

    Now you have to get rid off your comment feeds, too. There's a hook "post_comments_feed_link". See this post:
    http://wordpress.org/support/topic/288260

    This works for me, if anyone got a better solution, share it, but I think it's quite simple.

  26. Florin

    I've got a problem with comments feed on http://drumliber.ro

    Instead of seeing a page or article, sometimes (quite often) I get the comments feed of another random article. It's completely random, I cannot see a rule for this bug.

    It might be a server problem, but there should be a way to fix it in the application. A way should be to check if the link in the address bar contains /feed and only then to show a feed. How can one do that?

    Thanks a lot!

  27. mr.e

    This works for categories, but the post's feed still remains.

    i.e: using a permalink structure of /%category%/%postname%/

    http://domain/category/postname/feed/

  28. AndyiBM

    Is there a way to disable only some of the feeds? If WordPress is used as a CMS on a site that also contains a blog, then can all posts within the 'blog' still have their own feed, but any other posts used for the site itself be disabled?

  29. AndyiBM

    Hiya,

    I was eventually directed on the WordPress forum to te following post which helped me to pick out one specific category for a feed:
    http://www.problogdesign.com/wordpress/how-to-edit-the-wordpress-rss-feed/

    Also, I needed to get rid of the RSS icon in the address bar for another site, and Basti's solution above didn't help as I didn't have the particular line of code in my header.php, but I found this solution from hollywoodgrind on the WordPress forum: http://wordpress.org/support/topic/remove-feed-from-wp_head

    Now I'm sorted :)

  30. Ryan

    Option 3: remove the feed rewrite rules with a plugin.

  31. Robert

    I updated functions.php with the disable RSS code and it works perfectly for the secure URL: https:// mysite.com/feed, however the non-secure URL mysite.com/feed still shows the RSS feeds in both IE8 and Firefox!

    Any suggestions why RSS is blocked in HTTPS but not in HTTP are appreciated.

    Thanks

  32. Robert

    The problem with HTTPS and HTTP was something to do with caching on my Windows PC despite closing and restarting the web browsers. RSS is blocked correctly after rebooting.

  33. Dan

    This works great. Does anyone know how to turn the feeds back on? For example, if I called fb_disable_feed() and then later wanted to do something like bf_enable_feed().

5 pingbacks

  1. 10 Useful RSS-Tricks and Hacks For WordPress | Developer's Toolbox | Smashing Magazine
  2. 10个优化WordPress RSS Feed的技巧(2) - 幸福收藏夹
  3. The Ambuscade
  4. 我想网 » Blog Archive » wordpress的十个有用的RSS技巧
  5. WordPress plugin: Feedkillah // digitalize.ca