Home › Forums › General Issues › Get ALT tag for image inside repeater › Reply To: Get ALT tag for image inside repeater
I think I figured it out. I was using ‘Image URL’ and needed to switch to ‘Image Array’ and change the code to the following. If someone could confirm I’m doing this correctly that would be great.
<?php while(the_repeater_field('banner')): ?> <?php $image = get_sub_field('image'); ?> <div> <h1><?php the_sub_field('heading'); ?></h1> <p><?php the_sub_field('description'); ?></p> <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>"> </div> <?php endwhile; ?>
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’re reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 Advanced Custom Fields.