theme development – ACF get_sub_field ALT TAG in the repeater doesn’t show


See here for ACF image docs.

If image field is set to return as an array then you need store the image subfield into a variable and use the variable to output the array keys.

So in your case, it would be like this…

<?php while( have_rows('logo_list') ) : the_row();?>
     <?php $image = get_sub_field('image'); ?>
     <li><img src="<?=$image['url']?>" alt="<?=$image['alt']?>" /></li>
<?php endwhile;?>

Use the code below inside your loop to dump your $image variable data so you can see all the image sizes and other image data.

echo '<pre>' . print_r($image, true) . '</pre>';

Very strange what is happening here.

Before your loop try adding this to see all the data in the field.

<?php global $post; ?>
<?php $field = get_field('logo_list', $post->ID); ?>
<?php echo '<pre>' . print_r($field, true) . '</pre>'; ?>

Post the output when you’ve done this.

Tanya Nami 4 months 2022-07-24T12:38:22-05:00 0 Answers 0 views 0

Leave an answer