How to Disable WP REST API in WordPress

Posted by Lasantha Bandara on January 12th, 2016 File Under : wordpress0 Comment


With WordPress 4.4, a new feature called "WP REST API (WP API / WordPress REST API / WordPress JSON API / WordPress JSON REST API)" was introduced. WordPress JSON Rest API makes it possible to access your WordPress website's data through an easy-to-use HTTP REST API, which is awesome for external services and clients. But everyone are not using this feature in their websites. For some reason if don’t want to use it, disable WordPress REST API simply adding the below code into your theme's functions.php file:

// 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');

You can read more about "WordPress JSON API" here:

File Under : wordpress

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.