WordPress is no longer just a blogging platform, and with its use as a CMS growing steadily there is even more reason for you to want to remove its RSS feed.

If you’re using WordPress to manage your online portfolio or to manage your company’s website, there’s no real use to having an RSS feed, and you might not even want it to be available to anyone.

So here’s a clean way of removing your RSS feed.

The Fix

You might have come across some sources suggesting you adjust some code in your core files to remove your RSS feed, however, while this may seem easy, it will require you to make this adjustment for every update of WordPress. Besides that, it’s also not recommended to adjust any core files.

The easier (albeit slightly longer) method is to add the following code to your theme’s functions.php file:

 * 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);

How It Works

What this code snippet does is it deactivates feeds via hook in your theme. The feed itself is not deleted, however, while the feed URL would still exist, if the user inputs the URL directly he won’t get any content. Instead he’ll be presented with the text you set in the code above.

In this case it would say “No feed available, please visit our homepage!”, with “homepage” linking to your blog’s homepage.

Source: WP Engineer

Published by Mark Zahra

Project Manager - WP RSS Aggregator

Leave a Reply

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