this is a follow up to this question advanced custom fields can't do nested loops repeater inside repeater have_rows() not doing anything
Now I'm stuck on a problem where I can't get the sub field URL.
<div class="tc__agenda-speaker">
<?php while (have_rows('agenda_event_speakers')) : the_row(); ?>
<div class="tc__agenda-speaker-headshot">
<!-- DEBUG LINE -->
<div style="color: red;"><?php echo the_sub_field('agenda_event_speaker_headshot')['src'] ?></div>
<img src="<?php the_sub_field('agenda_event_speaker_headshot')['url'] ?>" alt="<?php the_sub_field('agenda_event_speaker_headshot')['alt'] ?>">
</div>
<div class="tc__agenda-speaker-info">
<h4><?php the_sub_field('agenda_event_speaker_name') ?></h4>
<p><?php the_sub_field('agenda_event_speaker_title') ?></p>
</div>
<?php endwhile ?>
</div>
<?php endif ?>
This line
<?php the_sub_field('agenda_event_speaker_headshot')['url'] ?>
It's output is this
16835, 16835, Name color 2, Name-color-2.png, 152744, http://website.com/wp-content/uploads/2021/02/Name-color-2.png, http://website.com/post/post-title-here/Name-color-2/, , 86, , , Name-color-2, inherit, 16799, 2021-02-02 16:45:53, 2021-02-02 16:45:53, 0, image/png, image, png, http://website.com/wp-includes/images/media/default.png, 500, 500, Array
The fields returns format is array
Advanced Custom Fields get sub field image
You can use get URL of Image by get_sub_field('imgcolumn_1')['url'];
As function get_sub_field() returns an array.
this documentation https://www.advancedcustomfields.com/resources/the_sub_field/ indicates there's no difference in accessing indexes
It does say
This function is essentially the same as echo get_sub_field()
If I go
<?php echo the_sub_field('agenda_event_speaker_headshot')['url'] ?>
the img src is unknown
How do you access url index of image array in a sub field in advanced custom fields?