Home Add tag field to ACF image Gallery REST response
Reply: 0

Add tag field to ACF image Gallery REST response

user1087
1#
user1087 Published in May 20, 2018, 10:11 am

I'm trying to add a tag field to ACF image Gallery REST response. I Currently display tags from each image from ACF gallery with these multiple steps :

  • get all images from the gallery via REST API
  • check there ID
  • get all medias from WP via REST API
  • check there ID
  • compare IDs from images and medias, if it's match :
  • get all tags of this section of medias (custom field added to all medias)
  • compare mediasTag iD with tagsId, if it's match :
  • I finally the list of tagId I need for each image of the gallery...

I'm pretty sure there is a better way to achieve this.

Below an extract example of what I would like to receive from REST.

 "acf": {
 "gallery": [
  {
    "id": 173,
    "title": "03",
    "filename": "03.jpg",
    "url": "http://localhost:8888/03.jpg",
    "alt": "",
    "author": "1",
    "description": "",
    tags : // HERE I WOULD LIKE TO DISPLAY TAGS SLUG ARRAY ABOUT EACH IMAGE LIKE 
    ...

Thanks for your advices.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310039 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO