Home › Forums › Add-ons › Gallery Field › Gallery field – echo a custom taxonomy as a class in the image container › Reply To: Gallery field – echo a custom taxonomy as a class in the image container
Thanks! This did work. I had tried something similar but was using “$image->ID”
It took me bit to figure out where to put it. In case anyone else is wondering, you need to put it INSIDE the foreach statement!
<?php
$images = get_field('images');
if( $images ): ?>
<?php foreach( $images as $image ):
$terms = wp_get_object_terms($image['ID'], 'image_category');
?>
Another WP genius was helping me and had suggested using wp_get_post_terms, which also works.
Thanks so much for your help!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.