Yes, an array is definitely what I was looking for. I knew i was close, just couldn’t put my finger on it. Thank you for the insight!
Now, just to be clear then, the declaration portion of the code would look like:
$tracks = array();
<?php if( have_rows('audio_samples_parent') ): ?>
<?php while( have_rows('audio_samples_parent') ): the_row();
$tracks[] = get_sub_field('audio_tracks'); ?>
<?php endwhile; ?>
<?php endif; ?>
and then to loop through the values, i would then call:
<?php
if( have_rows('audio_samples_parent') ): ?>
<ul>
<?php
while( have_rows('audio_samples_parent') ): the_row();
?>
<li>
<audio controls>
<source src="<?php echo $tracks; ?>" type="audio/mpeg">
</audio>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
Not sure if this is 100% right or not but any more info you can send my way is highly appreciated. Thanks!
Hi guys, got this figured out. Turns out rather than trying to define a “$tracks” variable, which can obviously only store one item, i left out the sub-repeater loop in the declaration area and simply used
<div class="talenthalf"><strong><u>Audio Samples</u><br />
<?php
if( have_rows('audio_samples_parent') ): ?>
<ul>
<?php
while( have_rows('audio_samples_parent') ): the_row();
?>
<li>
<audio controls>
<source src="<?php the_sub_field('audio_tracks'); ?>" type="audio/mpeg">
</audio>
</li>
<?php endwhile; ?>
</ul>
<?php endif;
?>
</strong></div>
to loop through the files uploads. Hope this helps someone else!
Bump. Any help is appreciated guys; just figuring out how to store/echo multiple files within the $tracks variable. Thank you for your help!
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.