How to disable RSS Feeds in WordPress

Guy Dumais
Guy Dumais

What are WordPress RSS Feeds?

RSS Feeds allow your visitors to subscribe to your blog posts. On the other hand, if your site does not contain any blog post as is the case in the majority of web microsites, it is better to disable this feature of WordPress which generates HTML code downloaded by the client unnecessarily. The speed of delivery of a web page is one of the many factors that promotes a good ranking in search engines, so it is better to eliminate all unnecessary code.

PHP code to disable RSS Feeds

Here is the PHP code to disable all RSS Feeds features in WordPress. Simply copy and paste this PHP code into the functions.php file of your WordPress theme.


PHP Code Features

  • INIT Action: We inject this code into the init action hook, which is executed before the wp_enqueue_scripts, the step where the RSS Feeds are loaded among other stylesheets and javascript codes.
  • Anonymous Function: By using an anonymous function rather than a named function, we save memory in the Global Namespace, which is already heavily loaded by WordPress and third-party plugins. Read my article How to disable Emojis in WordPress for more details about this personal twist.
  • PHP Memory Release: Finally, we use the PHP unset($af) instruction to free out memory from the dynamically created anonymous function. Read my article How to disable Emojis in WordPress for more details.