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.