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.

8 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.

4 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技巧
Leave a Reply
Sponsors

Would you like to advertise here? Click here for more information.

Recent Posts
Recent Comments
Categories
Most Popular Posts
Archive