Hi friend, hope you are doing good. From 4.4 version WordPress has added the much-anticipated JSON REST API in build with WordPress Software. It is very helpful for theme & plugin developers, but many website owners may not find it useful for his WordPress websites at all.
So that in this tutorial, I will explain how to disable JSON REST API in WordPress websites. If you want to disable the REST API from your WordPress site, then keep your close attention in this post and follow the steps which I have mentioned below.
Add below code snippet at the end of the functions.php file in your current activated WordPress theme folder. Below WordPress filters will disable the JSON Rest API features from your WordPress blogs or websites.
// Filters for WP-API version 1.x
// Filters for WP-API version 2.x
There is also another option to disable the JSON REST API on your site. You can simply install this plugin and it will disable the REST API feature from your site.
This plugin works well with WordPress 4.4, 4.5, 4.6 and for the above version, it will return an authentication error that is you need to login to the website to access the JSON REST API.
Download the latest version of Disable REST API plugin from wordpress.org and installed it with your WordPress website. If you have just started with WordPress Read:
After installed, activate this plugin via Plugins menu option and then try to access the REST API by using
http://your-website-url.com/wp-json/ you will get an authentication error. See the below screenshot.
If you still need any help to disable the JSON REST API from your site, then feel free to add your comments in below comment section. I will be happy to help you to disable the JSON REST API on your site. Do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.