Tag rest api
-
GET
wp/v2/tags
returns a list of tags (20 by default) but there is no information about how many tags there are in totals. The only way I found to get all the tags is to issue multiple requests with the page parameter in the query string until I get a response with an empty array. Is there any other elegant solution?POST
wp/v2/tags
will return 409 if a tag already exists, but there are no other information about the tag itself, like the id:{ "code": "term_exists", "message": "A term with the name provided already exists in this taxonomy.", "data": { "status": 409 } }
The GET API only works with id, it doesn’t work passing a tag name. The only way I found to solve this is to prefetch all the tags with ids, store them in memory and check if the tag already exists before doing a POST request.
Again, is there any other way, a more efficient one, to solve this issue?Thanks
- The topic ‘Tag rest api’ is closed to new replies.