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 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.