Skip to main content

REST Route


This class is used to create a new REST API route.

To create a new class for the REST API route, run this command:

wp boilerplate create rest-route

The output will ask you to input the correct endpoint slug and method (POST, GET, etc.). Everything else will be done for you, setting the namespace, package, vendor prefixes, class, and folder name, and you will be set to write your field implementation in the routeCallback method.

Test it in action

To test it in action, you should check the wp-json path in your browser. You can do that with something like this:


This link will be different based on your project implementation.