How to Disable the REST API in WordPress?

Keeping REST API enabled for all users is useless. It’s better to block REST API for unwanted users.

Here is a simple solution to Disable the REST API in WordPress. Just copy the following code and paste inside your function.php file. This script will keep REST API only for Admin. 

				
					/** Disable REST API **/
// Filters for WP-API version 1.x
add_filter('json_enabled', '__return_false');
add_filter('json_jsonp_enabled', '__return_false');

// Filters for WP-API version 2.x
// add_filter('rest_enabled', '__return_false');
add_filter('rest_jsonp_enabled', '__return_false');
				
			

Disable REST API using Adminify Plugin

There are some people who likes to avoid coding but wants to achieve the output. You can install Adminify Plugin then from your Dashboard, click on WP Adminify option. You will see Tweaks > WP JSON API. The first option is “Disable Rest API“, just enable it and save your settings.

Disable REST API in WordPress
Was this article helpful?

© 2021-2024 - Adminify | All rights reserved

WP Adminfy accepted payment methods