Custom Endpoint with Multiple Arguments/Parameters
-
I’ve developed a custom plugin for my project implementing several endpoints that take either no or one argument(s) and they are all working great.
Now I want to get a second parameter but if anything is wrong with the URL at all it will return a 404 so it becomes difficult to figure out what the exact problem is. Here is my latest attempt, which still returns 404:
add_action( 'rest_api_init', function () { register_rest_route( PLUGIN_NAMESPACE, '/v1/getstuff/(?P<slug>[a-z0-9\-]+)/(?P<secondparam>[a-z0-9\-]+)', array( 'methods' => 'GET', 'callback' => 'myFunctionToGetStuff', )); });How do I add additional parameters to a custom endpoint?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
The topic ‘Custom Endpoint with Multiple Arguments/Parameters’ is closed to new replies.