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.


27 Comments
  1. SE7EN says:

    I deleted/renamed php files relate to feed

  2. Dave says:

    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 says:

    Dave, do you have php start and end tags?

    < ?php
    //the complete code
    ?>

  4. Dave says:

    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 says:

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

  6. Dave says:

    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 says:

    Yes, ask him for help.

  8. Michael says:

    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. 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 says:

    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 says:

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

  12. Hansi says:

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

  13. Michael says:

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

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

  15. Frank says:

    @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 says:

    @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 says:

    @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 says:

    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 says:

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

  20. Frank says:

    @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 says:

    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 says:

    Thanks for sharing this wonderful tip!

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

  23. Lee says:

    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 says:

    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 says:

    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 says:

    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 says:

    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/

5 Pings
  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
Leave a Reply