As you probably already heard, REST API provides you with the ability to interact with your WordPress site externally, for example, from a mobile application or another website.
Let’s look at a short code example that describes how you can fetch posts from the CSS Tricks website on your site:
You can also add parameters to the request, for example, the number of posts you want to fetch, by adding parameters to the array. Here is the same code that limits the number of posts fetched from CSS Tricks to only four (pay attention to the difference in lines 5-7):
How to Completely Disable REST API /wp-json on Your Site
What if you don’t want anyone to interact with your site’s API to, for example, get posts without permission? In this case, you need to disable /wp-json/
. The following code will work in WordPress 4.7 and above:

That’s it.