Home › Forums › ACF PRO › Get Value of Sub-Field Outside of While Loop › Reply To: Get Value of Sub-Field Outside of While Loop
I was able to figure it out. Never was able to get to the sub_field outside of the second nester so I put in a counter. In hindsight, it seems incredibly glaringly obvious but oh, well! Pasting for anyone else who might have the need. It might not be the smartest way to go about it but this did the trick for me:
<?php
if( have_rows('affiliations_&_links', 'option') ):
while( have_rows('affiliations_&_links', 'option') ): the_row();
if( have_rows('affiliations_repeater', 'option') ):
$x = 1;
echo '<ul>';
while( have_rows('affiliations_repeater', 'option') ): the_row();
echo '<li>';
// Flag for the first row
if ($x==1) :
echo '<h5>';
echo the_sub_field('link_type', 'option');
echo '</h5>';
else : endif;
echo the_sub_field('al_name', 'option');
echo '</li>';
$x++; endwhile; // ends affiliation repeater
echo '</ul>';
endif; // ends affiliation repeater
endwhile; // ends affiliation and links
endif;// ends affiliation and links
?>
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.