How to disable feeds in WordPress

Disabling the news feed in WordPress can be useful if you want to prevent your posts from automatically showing up in RSS feeds. Here are a few ways to do this:

1- Using the plug-in

The easiest way is to use a plugin that manages news feeds. Here are a few popular plugins:

  • Disable Feeds: This plugin allows you to disable all RSS feeds on your site.
  • WP Disable: This plugin offers many options to disable various WordPress features, including news feeds.

Install and activate one of these plugins, and follow the on-screen instructions to customize.

2. Changing the theme's functions

If you don’t want to use the plugin, you can disable news feeds by adding code to the functions.php file of your active theme.

To do this:

  • Go to Appearance → Theme Editor in the WordPress admin.
  • Locate and open the functions.php file.
  • Add the following code to the end of the file:

    // Disabling all RSS feeds
    function disable_all_feeds() {
    wp_redirect(home_url());
    exit();
    }

    add_action(‘do_feed’, ‘disable_all_feeds’, 1);
    add_action(‘do_feed_rdf’, ‘disable_all_feeds’, 1);
    add_action(‘do_feed_rss’, ‘disable_all_feeds’, 1);
    add_action(‘do_feed_rss2’, ‘disable_all_feeds’, 1);
    add_action(‘do_feed_atom’, ‘disable_all_feeds’, 1);

  • Save your changes.

This code redirects requests for RSS feeds to the home page of your site.

3. Editing .htaccess

You can use a .htaccess file to block access to news feeds. Add the following code to the .htaccess file that is located in the root directory of your WordPress site:

# Blocking RSS feeds
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/feed/ [OR]
RewriteCond %{REQUEST_URI} ^/feed/?$
RewriteRule ^(.*)$ – [R=404,L]

This code will return a 404 error for all RSS feed requests.

4. Through security plug-in settings

Some security plugins, such as Wordfence or iThemes Security, may offer options to control or disable RSS feeds. Check the settings of your security plugin, if installed.

Choose the method that best suits your requirements and skills. Each is effective, but a plugin may be the easiest option for beginners.

Useful articles