To get a taxonomy, using WP-API, you should make a request to http://example.com/wp-json/taxonomies/category/
All is well, until you have a taxonomy with a dash(‘-‘) in its name – in my case, the taxonomy is called ‘event-categories’ – the default event taxonomy in the Events Manager plugin.
So, a request to http://example.com/wp-json/taxonomies/event-categories/ responds with a “No route was found matching the URL and request method” message.
It’s a pretty big, apparently known issue, and will hopefully be resolved soon. In case it’s not though, here is a temporary solution, stolen from GitHub user zkingdesign on this page:
1 2 3 4 5 6 7 8 |
function ONetWPAPIDashFix ( $endpoints ) { $new_endpoints = array(); foreach ( $endpoints AS $match => $data ) { $new_endpoints[ str_replace( ‘w+’, ‘(?:[w-](?<!_))+’, $match ) ] = $data; } return $new_endpoints; } add_filter(‘json_endpoints’,‘ONetWPAPIDashFix’,10,1); |