In this article, we will show you how to easily disable JSON REST API in WordPress.
Why Disable JSON REST API in WordPress?
There is no doubt that the API will bring many new features for WordPress developers. However, some site owners simply don’t need such features. The API makes it very easy to get data using GET requests. It is very useful for developing applications with WordPress.
And this all potentially opens your site to a new front of DDoS attacks, which can take up a lot of resources and, as a result, slow down your site.
This method is similar to disabling XML-RPC, which many administrators have already done on their WordPress sites, just in case.
Disable JSON REST API in WordPress
If you want to disable the JSON REST API on your WordPress site, you can do so simply by adding the following code to your theme’s functions.php file or WordPress site plugin:
add_filter (‘json_enabled’, ‘__return_false’);
add_filter (‘json_jsonp_enabled’, ‘__return_false’);
The code uses built-in filters to disable JSON and JSONP APIs.
For those who do not want to manually add code, you can install and activate the Disable JSON API plugin. The plugin works out of the box, and does not contain additional options for its configuration. Simple plugin activation will disable the API on your site.
We hope this article helped you learn how to disable Disable JSON API in WordPress.