How to disable RSS feeds completely in WordPress?

You want to disable RSS feeds completely in WordPress, but you don’t know how? Here are 3 ways to do it.


Even though they are still used regularly by many people, nowadays RSS feeds are not as popular as they were a decade ago. And there are plenty of valid reasons why you might want to disable them on your WordPress website.

3 ways to disable RSS and Atom feeds for WordPress websites

Use a plugin

Installing a plugin that will take care of disabling feeds is probably the easiest way to proceed, above all if you’re not comfortable with playing with the code.

There are a couple of plugins that can allow you to disable feeds, but most of them come with other features you might not need. However, the Disable Feeds plugin can take care of disabling RSS feeds without bloating your WordPress install with other unwanted features.

Use WordPress hooks and add the following lines to your functions.php file

This is personally what I recommend. In most cases, a plugin isn’t needed in order to disable feeds, since feeds can be disabled with only a couple of lines of code.

In order to disable feeds, you can simply add the following lines at the end of the functions.php file of your current theme:

 * Redirect to the homepage all users trying to access feeds.
function disable_feeds() {
	wp_redirect( home_url() );

// Disable global RSS, RDF & Atom feeds.
add_action( 'do_feed',      'disable_feeds', -1 );
add_action( 'do_feed_rdf',  'disable_feeds', -1 );
add_action( 'do_feed_rss',  'disable_feeds', -1 );
add_action( 'do_feed_rss2', 'disable_feeds', -1 );
add_action( 'do_feed_atom', 'disable_feeds', -1 );

// Disable comment feeds.
add_action( 'do_feed_rss2_comments', 'disable_feeds', -1 );
add_action( 'do_feed_atom_comments', 'disable_feeds', -1 );

// Prevent feed links from being inserted in the <head> of the page.
add_action( 'feed_links_show_posts_feed',    '__return_false', -1 );
add_action( 'feed_links_show_comments_feed', '__return_false', -1 );
remove_action( 'wp_head', 'feed_links',       2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );

This will completely disable all types of feed (RSS, RDF, Atom) for all types of content (blog posts, comments, custom post types, etc.) and redirect to the homepage any user trying to browse the feeds. This will also remove the <link rel="alternate" type="application/rss+xml" href="/feed/" /> tag inserted by default in the <head> of your page for both comment and post feeds.

Add rules to the .htaccess file to prevent access to the feeds

This is not my favorite option, but it’s still valid and it works, as long as your website is served by Apache. You can add the following rules in your .htaccess file, before the # BEGIN WordPress line (if you don’t see that line, then add these rules at the beginning of the file) :

# BEGIN Feed redirect
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*/)?feed(/rss|/rss2|/atom|/rdf)?/?$ /$1 [R=301,NC,L]
RewriteCond %{QUERY_STRING} (?|&)feed=
RewriteRule (.*) $1/? [R=301,NC,L]
# END Feed redirect

With that piece of code added to your .htaccess file, it will work whether you have enabled custom permalinks or not, and trying to browse any feed will redirect the user either to the homepage of your site, or to the corresponding post/author/archive page.

If you know another way of disabling RSS feeds in WordPress, feel free to share it with us in the comments!

Leave a comment

2 thoughts on “How to disable RSS feeds completely in WordPress?

  1. Hi Dave,
    Thanks for your great article!
    I need to disable the author’s feed,
    I have already disabled author pages (on function.php to 404 page so google will permanently remove these pages from index) but author’s feeds are still running.
    So I need to point to 404 pages like /author/name/feed.
    Can you help me in some way?

  2. Hi Frank,

    If you only want to disable feeds for authors, you could use the following:

     * Redirect to the homepage all users trying to access author feeds.
    function disable_author_feeds() {
    	if ( is_author() ) {
    		wp_redirect( home_url() );
    // Disable global RSS, RDF & Atom feeds.
    add_action( 'do_feed',      'disable_author_feeds', -1 );
    add_action( 'do_feed_rdf',  'disable_author_feeds', -1 );
    add_action( 'do_feed_rss',  'disable_author_feeds', -1 );
    add_action( 'do_feed_rss2', 'disable_author_feeds', -1 );
    add_action( 'do_feed_atom', 'disable_author_feeds', -1 );

    Hope it helps!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Dave Lavoie
Co-Founder of WP Captain, I'm a senior WordPress developer and solutions architect. I lead all WordPress development efforts and provide advanced customer support to our users.

We keep your WordPress sites running nicely

Hosting, maintenance & security solutions by experienced WordPress DevOps.