How To Disable The JSON Rest API In WordPress Without A Plugin

WordPress has included the JSON Rest API in WordPress core since version 4.4. The JSON Rest API allows users to build applications that connect and interact with their website. The JSON Rest API a fantastic feature from a developer standpoint because it created new interesting features. However, on a large scale, the feature is completely under used by most of the WordPress user base. Most WordPress users are unaware that you can disable the JSON Rest API.

Many users are even unaware that the JSON Rest API is enabled on their website and many are likely not using it. Some website owners do not like having unnecessary features enabled on their website and like to disable them.

Disable the JSON Rest API

The code below will allow you to disable the JSON Rest API without installing a plugin. Add the code to one of the following places:

  • functions.php file
  • site-specific plugin
add_filter('json_enabled', '__return_false');
add_filter('json_jsonp_enabled', '__return_false'); That's all there is to it!
scott hartley

About the author

Scott is a web performance geek, lover of all things coffee, and avid video game player. His WordPress work delves into web performance, web security, and SEO.

Leave a Comment