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

Question

See here for ACF image docs.

https://www.advancedcustomfields.com/resources/image/

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.

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

Leave an answer

Browse
Browse