New Check out the curated list of the finest design resources I've gathered for you! Take a look →

How to Disable WordPress REST API (2 Methods)

This guide will walk you through the process of disabling the WordPress REST API using two different methods. By disabling this API, you can improve the security and performance of your WordPress site.

Requirements

For this tutorial, you need:

  • A WordPress website
  • Administrative access to the WordPress dashboard

Method 1: Using the “Disable REST API” Plugin by Dave McHale

  1. Go to the WordPress dashboard and install the “Disable REST API” plugin by Dave McHale.
  2. Activate the plugin.
  3. Follow the instructions provided by the plugin to disable the REST API.

Method 2: Adding a Filter to the Functions.php File

  1. Add the following code filter to the functions.php file of your WordPress theme:

add_filter('rest_authentication_errors', 'disable_rest_api');

  1. Create a function with the name 'disable_rest_api' and add the necessary code to disable the REST API. You can use a plugin like Code Snippet to add the function or directly modify the functions.php file.

Wrapping Up

I hope this short article has provided you with a helpful guide on how to disable the WordPress REST API using two different methods. By disabling this API, you can enhance the security and performance of your WordPress site. For more insightful tips and articles, feel free to explore my other resources.

Rizwan Aritonang

An independent WordPress & Front-End Developer from Bandung, Indonesia.

Get In Touch

Leave a Comment