How to disable RSS Feeds in WordPress

Disable RSS Feeds in WordPress if your site does not contain blog posts to eliminate HTML code unnecessarily generated on the client side and gain additional SEO performance.

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.

functions.php
after_setup_theme 3 Init 16 wp_enqueue_scripts

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.

Disable RSS Feeds in one click

The high-performance WordPress theme Apace allows you to disable the RSS Feeds with a single mouse click, along with several other SEO settings for WordPress. See image below:

Comments