Support

Account

Home Forums Add-ons Repeater Field Repeater within another repeater

Solved

Repeater within another repeater

  • Is it possible to have a repeater field within another repeater field? I’m having difficulty the code below to work. The first repeater is working fine, but when it gets down to the second if/while the logic fails and the div is empty. Am I missing something?

    <?php if(get_field('partnership_1')) {
    $number = count($rows);
    while(the_repeater_field('partnership_1')) { ?>
    <div class="stable-horse clearfix">
      <div class="stable-pic">
        <img src="<?php echo get_sub_field('image'); ?>" />
      </div>
      <div class="stable-content">
        <ul>
           <li><h3><?php echo get_sub_field('name'); ?></h3></li>
           <li><?php echo get_sub_field('age'); ?></li>
           <li>By: <b><?php echo get_sub_field('by'); ?></b></li>
           <li>Out of: <b><?php echo get_sub_field('out_of'); ?></b></li>
           <li><i><?php echo get_sub_field('misc') ?></i></li>
        </ul>
    <div style="position:relative;z-index:10;">
       <a href="<?php echo get_sub_field('pedigree'); ?>" class="button">View Pedigree</a>
    <?php if (get_sub_field('winners_circle_gallery')) { ?>
        <a href="#winners-circle<?php echo $number; ?>" rel="modal:open" class="button basic">Winner's Circle Gallery</a></div>
    <?php } else {?> 
    </div>
    <?php } ?> 
    <div id="winners-circle<?php echo $number; ?>" class="modal" style="display:none;">
    
    <!--------THIS IS WHERE THE CODE FAILS-------->
    
    <?php if(get_field('winners_circle_gallery')) { ?>
    <div class="flexslider">
       <ul class="slides">
         <?php while(has_sub_field('winners_circle_gallery')) { ?>
           <li><img src="<?php get_sub_field('image'); ?>" /></li>
         <?php } ?>
       </ul>
    </div>
    <?php } ?>							
    </div>
    </div>
    </div>
    <?php $number -= 1; ?>
    <?php }} ?>
    • Elliot

    • July 16, 2013 at 12:49 pm

    Hi @jacobklos

    Before I read over the code, have you read this article?
    http://www.advancedcustomfields.com/resources/tutorials/working-with-nested-repeaters/

  • Thanks, Elliot. The “if” statement of the nested repeater should be get_sub_field NOT get_field like I had it.

    Thanks for the response and kudos on an excellent plugin. I use it for everything.

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

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.