WordPress Snippets

How to Disable RSS Feeds in WordPress

By ThemesDNA2 min read

Share:

Would you like to turn off RSS feeds on your WordPress site? People can subscribe to your blog posts with RSS feeds. But if you're making a small, static website, you might want to turn off the RSS feeds. WordPress doesn't have a way to get rid of RSS feeds by default.

By adding the below code snippet to your functions.php file, you can disable all the feed addresses and remove feed links from the header.

// A message to display instead of the feeds.
function themesdna_disable_feed() {
    wp_die(
        sprintf(
            // Translators: Placeholders for the homepage link.
            esc_html__( 'No feed available, please visit our %1$shomepage%2$s!' ),
            ' <a href="' . esc_url( home_url( '/' ) ) . '">',
            '</a>'
        )
    );
}

// Replace all feeds with the message above.
add_action( 'do_feed', 'themesdna_disable_feed', 1 );
add_action( 'do_feed_rdf', 'themesdna_disable_feed', 1 );
add_action( 'do_feed_rss', 'themesdna_disable_feed', 1 );
add_action( 'do_feed_rss2', 'themesdna_disable_feed', 1 );
add_action( 'do_feed_atom', 'themesdna_disable_feed', 1 );
add_action( 'do_feed_rss2_comments', 'themesdna_disable_feed', 1 );
add_action( 'do_feed_atom_comments', 'themesdna_disable_feed', 1 );

// Remove links to feed from the header.
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
Premium WordPress themes Made for WordPress   /   Ready for your story

Ready to Build?

Your next great website starts here.

Build more websites with one flexible collection—and keep every theme for life.

  • 56+ themes
  • Lifetime updates
  • Unlimited websites
  • No renewals

The complete collection

$75

One payment. No renewals.

Get the Themes Bundle — $75Purchase terms