Custom Term
These routes allow you to get/create/update/delete terms or a single term of a custom taxonomy.
Any new taxonomy registered via register_taxonomy() receives a base route handler WP_REST_Terms_Controller{}. See the parameter rest_controller_class.
This means that when registering a taxonomy, if the parameter rest_controller_class
is set, we automatically have routes that are completely analogous to the routes for tags and categories, just in the route path instead of tags
or categories
you need to use the slug of the created taxonomy
:
/wp/v2/my_taxonomy // works with terms of the my_taxonomy /wp/v2/my_taxonomy/{ID} // works with a single term {ID}
Otherwise, these routes are used exactly the same as the category routes.
To make the route work when registering a taxonomy, you need to specify show_in_rest = true
!
my_taxonomy
in the route /wp/v2/my_taxonomy
is the parameter rest_base
that is specified when registering the taxonomy. By default = the slug of the taxonomy.