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:
The easiest way is to use a plugin that manages news feeds. Here are a few popular plugins:
Install and activate one of these plugins, and follow the on-screen instructions to customize.
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:
// 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);
This code redirects requests for RSS feeds to the home page of your site.
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.
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.
Contacts
Have a question?