Hiding WordPress REST API v2 endpoints from public viewing

Posted by Prem Tiwari | Updated on

The simplest way to do this is to extend the WP_REST_Posts_Controller. Here’s a very simple example of that:

You can then register your custom post type with REST API support by adding the following arguments in register_post_type

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers