By default, WordPress enables various types of RSS feeds, including those for taxonomies, authors, individual posts, and pages.
However, you might want to disable these RSS feeds for various reasons, such as reducing server load, avoiding content scraping, or simply because your site doesn’t rely on RSS for content distribution.
It’s important to note that the Rank Math Plugin does not enable or disable RSS feeds on your website. WordPress automatically generates these feeds, and there is no built-in option to disable them.
In this knowledgebase article, we’ll guide you on how to disable RSS feeds in WordPress.
1 Disabling RSS Feeds in WordPress
To disable RSS feeds in WordPress, you’ll need to edit the functions.php
file of your active theme.
First, back up your website to ensure easy recovery if anything goes wrong. Since you’ll be editing the functions.php
file, create a child theme, too, if you haven’t already, to prevent changes from being overwritten during theme updates.
Once you set up a child theme, access your File Manager or use an FTP client to connect to your website’s server. Navigate to the wp-content/themes/your-child-theme
folder, where you’ll find the functions.php
file.
Next, right-click to select or double-click to open the file and paste the following code into it:
// Disable RSS Feeds
function disable_rss_feeds() {
wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}
add_action('do_feed', 'disable_rss_feeds', 1);
add_action('do_feed_rdf', 'disable_rss_feeds', 1);
add_action('do_feed_rss', 'disable_rss_feeds', 1);
add_action('do_feed_rss2', 'disable_rss_feeds', 1);
add_action('do_feed_atom', 'disable_rss_feeds', 1);
add_action('do_feed_rss2_comments', 'disable_rss_feeds', 1);
add_action('do_feed_atom_comments', 'disable_rss_feeds', 1);
// Remove RSS feed links from header
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
Once you’ve done that, click the Save File button to save your changes.
Alternatively, you can access the file editor directly within your WordPress dashboard. Go to Appearance → Theme File Editor and select your theme from the right-hand sidebar.
Then, click on the functions.php
file. Paste the code there and click the Update File button to save the changes, as demonstrated below.
After disabling the RSS feeds, visit your website’s feed page (usually yourdomain.com/feed); it will display an error message instead of the RSS feeds, as shown below.
In case your changes don’t reflect on the feeds page, clear your website’s cache and reload the page.
If you don’t want an error message displayed when users access the RSS feeds page, use this code instead. It automatically redirects users to your homepage.
// Disable RSS Feeds and redirect to homepage
function disable_rss_feeds() {
wp_redirect(home_url());
exit();
}
add_action('do_feed', 'disable_rss_feeds', 1);
add_action('do_feed_rdf', 'disable_rss_feeds', 1);
add_action('do_feed_rss', 'disable_rss_feeds', 1);
add_action('do_feed_rss2', 'disable_rss_feeds', 1);
add_action('do_feed_atom', 'disable_rss_feeds', 1);
add_action('do_feed_rss2_comments', 'disable_rss_feeds', 1);
add_action('do_feed_atom_comments', 'disable_rss_feeds', 1);
// Remove RSS feed links from header
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
Note: If you’re uncomfortable adding code to your theme files, you can use a WordPress plugin like Disable Everything to easily disable your RSS feeds.
By following these steps and considering the alternative method, you can make an informed decision about disabling RSS feeds on your WordPress site.
That’s it! We hope this tutorial helped you disable RSS feeds in WordPress. If you have any questions about Rank Math, please feel free to reach out to our support team. They’re always here to help.