Disable RSS Feeds On Your WordPress Blog

How to Disable RSS Feeds On Your WordPress Blog

in RSS Feeds
Google+ LinkedIn

WordPress is one of the best Content Management System (CMS) available and it is such a well thought out flexible system that it can be used for any type of website. And since you can create multiple different types of sites, there is always going to be some features which aren’t needed or wanted on the other sites. For example, if you are building a static website with WordPress or photography portfolio website, then you probably do not need the RSS feeds to be available and want to disable RSS feeds completely. So in this article I will show you how you can easily disable RSS feeds of your WordPress website without editing the core file or using a plugin.

To disable RSS feeds you can paste this following WordPress snippet in your theme’s functions.php file. This code snippet will setup a function which will kill the current operation if it detects a request has been made to access RSS feeds. Now whenever a visitor tries to access the RSS feed, the text will be displayed with a link back to the home page.

// disable rss feeds on your wordpress blog
function wcs_disable_rss_feeds() {
    wp_die( __( 'Feed is not available. Please return back to the <a href="'. get_bloginfo( 'url' ) .'">homepage</a>!' ) );
}

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

Share the love

If you like this snippet, share it with others!

Leave a Reply

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