Home Forums Add-ons Repeater Field Syntax to Output Repeater Content in a Flexible Content Layout


Syntax to Output Repeater Content in a Flexible Content Layout

  • 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>';
  • 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): ?>
    						<?php echo $quote['subfieldname']; ?>
    				<?php endforeach; ?>
    		</div><!-- #testimonialsSlider1 -->											
    <?php endif; ?>

    Good luck!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.