I am trying to run custom plugin on wp 4.7.4 . Below is my simple plugin
add_action( 'rest_api_init', 'register_routes');
function register_routes() {
register_rest_route( 'taxonomy-manager/v1', '/taxonomies/(P<taxonomy_type>[a-zA-Z]+)', array(
'methods' => 'GET',
'callback' => 'get_or_insert'
) );
}
function get_or_insert( WP_REST_Request $request ) {
$parameters = $request->get_params();
return $parameters;
}
When I request wp-json
endpoint I see no plugin route there. Plugin was successfully activated. Have I missed something ? Does above plugin (or similar one based on rest_api_init
event) works for anybody else ? Thanks.
I got solution, You need to use wp-json with your URL... like https://yourdomain.com/wp-json/namespace/and-so-on/
Then it will work. I was missing wp-json in URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With