Hey everyone,
I’m in new territory here. I’ve got a repeater field within a flexible field.
The sub_field of “quotes” is actually the repeater, consisting of two fields (quote_text and attribution) within it. I want to loop through them in that unordered list wrapped in <li>
tags. I just am unfamiliar on how with the syntax to make this happen within a flexible content elseif.
elseif( get_row_layout() == 'quotes_slider' ):
$heading = get_sub_field('heading');
$quotes = get_sub_field('quotes');
echo '<div class="ctaContent ctaContent1 ctaTestimonials clearfix">';
echo '<h3>' . $heading . '</h3>';
echo '<div class="flexslider" id="testimonialsSlider1">';
echo '<ul class="slides">';
// Want to loop through repeater here, wrapped in <li> tags
echo '</ul>';
echo '</div><!-- #testimonialsSlider1 -->';
echo '</div>';
endif;
Hi @rkeefer
Here’s how you would do this based on the code you’ve provided
elseif( get_row_layout() == 'quotes_slider' ):
$heading = get_sub_field('heading');
$quotes = get_sub_field('quotes');
?>
<div class="ctaContent ctaContent1 ctaTestimonials clearfix">
<h3><?php echo $heading; ?></h3>
<div class="flexslider" id="testimonialsSlider1">
<ul class="slides">
<?php foreach($quotes as $quote): ?>
<li>
<?php echo $quote['subfieldname']; ?>
</li>
<?php endforeach; ?>
</ul>
</div><!-- #testimonialsSlider1 -->
</div>
<?php endif; ?>
Good luck!