This is definitely not supported at present, thank you for the catch. I believe I will add a .slug() method to the Taxonomies query builder to allow terms to be provided by slug; however, this depends on WP-API/WP-API#347, because the version of the API in the plugin directory does not support filtering taxonomy collection endpoints. I am not sure how to proceed in releasing this feature given that it is not in the officially-released version of the plugin.
What version are you using? You can try this query; in the latest "master" version of the plugin, it will return an array with a single element:
That makes sense. Filtering for taxonomy collections is not included in 1.1.1, so there won't be any way to get at a specific term until a new plugin version is released; I will add the .slug convenience method at that point.
The best I can offer is to filter down the returned collection:
It is not super efficient to request all terms each time, so you may want to request all of them and cache that collection locally in a variable or an LRU cache to speed up the retrieval.
In the intervening year, this has been broken again by the v2 beta upgrades: WP-API/WP-API#924 identifies that filter is not currently supported on the /categories or /tags endpoints.
WP-API/WP-API#2065 has been opened to identify whether this will ever be reinstated; in the meantime, #126 will add a demonstration of using the ?search parameter to slightly more efficiently retrieve a specific term by slug (basically the same "get them all and search for the one you want in the response" approach detailed above, but with less overhead due to the narrowing effect of ?search=the-slug).
In the docs (frontpage) it says:
This works with the ID, but not with the slug :(. Is this something that changed?
HOST/wp-json/taxonomies/post_tag/terms/42 works HOST/wp-json/taxonomies/post_tag/terms/sociaal-ondernemerschap doesn't
This may just have been a mistake on my part, I can't find a prior version of the API that did support this—I'll look into it today
This is definitely not supported at present, thank you for the catch. I believe I will add a
.slug()method to the Taxonomies query builder to allow terms to be provided by slug; however, this depends on WP-API/WP-API#347, because the version of the API in the plugin directory does not support filtering taxonomy collection endpoints. I am not sure how to proceed in releasing this feature given that it is not in the officially-released version of the plugin.What version are you using? You can try this query; in the latest "master" version of the plugin, it will return an array with a single element:
c.f. update: the actual PR that landed this change was WP-API/WP-API#401, not 347
The filter by slug is what I had in my code (and which I think worked last week?), but now it returns all items, and doesn't filter.
What version of the WP-API plugin are you using?
The latest stable from wordpress.org, 1.1.1
That makes sense. Filtering for taxonomy collections is not included in 1.1.1, so there won't be any way to get at a specific term until a new plugin version is released; I will add the
.slugconvenience method at that point.The best I can offer is to filter down the returned collection:
It is not super efficient to request all terms each time, so you may want to request all of them and cache that collection locally in a variable or an LRU cache to speed up the retrieval.
I think I'll update the WP-API on the server. Thnx for your input!
In the intervening year, this has been broken again by the v2 beta upgrades: WP-API/WP-API#924 identifies that
filteris not currently supported on the/categoriesor/tagsendpoints.WP-API/WP-API#2065 has been opened to identify whether this will ever be reinstated; in the meantime, #126 will add a demonstration of using the
?searchparameter to slightly more efficiently retrieve a specific term by slug (basically the same "get them all and search for the one you want in the response" approach detailed above, but with less overhead due to the narrowing effect of?search=the-slug).