Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 216
roshambo Avatar asked Sep 11 '26 09:09

roshambo


1 Answers

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/

like image 197
Fetrarij Avatar answered Sep 12 '26 21:09

Fetrarij



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!