Wordpress: How to disable feeds

rss
feeds
wordpress

#1

RSS Feeds are used by people to subscribe to your new content that you post and also to feed into third-party reader applications such as Feedly. This way they can read your fresh content on the go. However, not everyone uses the blogging portion of WordPress and for some businesses, in fact, might simply want to in WordPress disable RSS feeds altogether. This is then one less thing they have to worry about.

By default WordPress generates all kinds of RSS feeds that are built in, such as:

http://example.com/feed/
http://example.com/feed/rss/
http://example.com/feed/rss2/
http://example.com/feed/rdf/
http://example.com/feed/atom/

There are a couple different ways to disable RSS feeds in WordPress. You can do it with a plugin or with code.

  1. Disable RSS Feed with Plugin
  2. Disable RSS Feed with Code

The first way to disable a WordPress RSS feed is to use a free plugin like Disable Feeds. This plugin disables all RSS/Atom feeds on your WordPress website by redirecting all the requests. It also disables BuddyPress group feeds and bbPress forum feeds. It was actually created by the same developer that made the Disable Comments plugin as discussed in our other article. It is actively maintained and currently has over 20,000 active installs with a 4.9 out of 5 rating.

The second method to disable a WordPress RSS feed is to simply use code.

Important! Editing the source code of a WordPress theme could break your site if not done correctly. If you are not comfortable doing this, please check with a developer first.

Copy the following code into your WordPress theme’s functions.php file.

function itsme_disable_feed() {
 wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}

add_action('do_feed', 'itsme_disable_feed', 1);
add_action('do_feed_rdf', 'itsme_disable_feed', 1);
add_action('do_feed_rss', 'itsme_disable_feed', 1);
add_action('do_feed_rss2', 'itsme_disable_feed', 1);
add_action('do_feed_atom', 'itsme_disable_feed', 1);
add_action('do_feed_rss2_comments', 'itsme_disable_feed', 1);
add_action('do_feed_atom_comments', 'itsme_disable_feed', 1);

Now if a person visits an RSS feed on your site, domain.com/feed for example, they will see the following message: “No feed available, please visit the homepage”

WordPress also generates links to the RSS feeds within your webpage’s header. You can go one step further and remove these links from within your pages HTML code.

Copy the following code into your functions.php file to remove the header links to your RSS feeds.

remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'rsd_link');