javascriptwordpresstagswordpress-rest-apiwp-api

WP API Get Post Tags


Trying to get post tags with wordpress API - api call is /wp-json/wp/v2/posts

ourHTMLString += '<i class="fa fa-tags">"' + postsData[i].tags + '"</i>';

It is returning these values

"tags": [
        766,
        19,
        578
],

I need the tag name and href to this, not sure how to get this. I have tried postsData[i].wp:term[i].tag.name - cannot find a solution. Any help? thanks


Solution

  • I think you need to do another request to get this and use include to list only theses tags. eg: /wp-json/wp/v2/tags?include=766,19,578

    https://developer.wordpress.org/rest-api/reference/tags/