Support

Account

Home Forums General Issues Pulling Images of Tags using the_tags()

Solving

Pulling Images of Tags using the_tags()

  • Hey there awesome ACF Peeps,

    I have created a field within tags in order to set a featured image for every tag on my site. I was hoping to somehow pull those images in my archive page using something like the_tags()

    But instead of having the list of tags, I would like to get the list of images I have set up for every tag.

    I know this might be simple but I am quite new to this. Any support is really appreciated!

  • The only way to get the image is to get the terms associated with the post and then get the image form the term.

    
    $terms = get_object_terms($post->ID, 'tags');
    foreach ($temrs as $term) {
      $image = get_field('image-field', $term);
    }
    
  • Hey there @hube2, thanks so much for your help.

    I tried adding the above (there is a small typo in there by the way at the $terms as $term) and then echo $terms at the location I wanted the images to appear but it didn’t happen.

    Just in case I tried echo $image, echo $term and echo $terms 🙂

    I am totally new as well. 😀

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.