Support

Account

Home Forums Add-ons Repeater Field Nested Foreach on ACF Repeater Reply To: Nested Foreach on ACF Repeater

  • OK I tried to narrow the code down to the section with the repeaters. Short explanation: Agenda day is a repeater. Inside that is the agenda schedule, and nested inside that is the agenda list of events (repeater) and each event had speakers (repeater). And inside that each speaker has their own fields. At the time this was an extremely ambitious project for me and do not think I would undertake it again. Note that there were other ACF fields on the page to build a slideshows, sponsor scrollers and other info all built with ACF. The calls for each repeater are basic and the trick was to call the repeater fields correctlly so that the sub_fields, including the nested repeaters could then be displayed. Again, I am not a master coder and do not claim this was completely correct at the time. I think the only way I could do this was because I didn’t know better LOL.

      <div id="fullagenda">                                            
    <?php if( have_rows('daily_agenda')): ?>
    	<ul>	
     	<?php  while ( have_rows('daily_agenda') ) : the_row();  ?>
        	<li>
                <div class="bluetitle" style ="background: <?php the_field('event_color'); ?>;">
                    <div class="container">
                        <div class="row">
                            <div class="col-md-12">
                                                                        
                                <h3><?php the_sub_field('agenda_day'); ?></h3>
                            </div><!-- col-md-12 -->                                          
                        </div><!-- .row -->                                    
                    </div><!-- .container -->
                </div><!-- #bluetitle -->                                                 
                <div class="fullagenda">
                    <div class="container">
                        <div class="row">
                            <div class="col-md-12">
                            
                               <?php if( have_rows('agenda_schedule')): ?>                                    
                                <ul class="agendaul">  
                                                    
                                        <?php while ( have_rows('agenda_schedule') ) : the_row();  ?>
                
                                            <li class="agendali">
                                            	
                                                <div class="timeplace">
                                            
                                                        <div class="timeline">
                                                        
                                                        <p><?php the_sub_field('time_range');?></p>
                                                        
                                                        </div><!-- .timeline -->
                                                        
                                                        <div class="venue">
                                                        
                                                        <p><?php the_sub_field('venue');?></p>
                                                        
                                                        </div><!-- .venue -->
                                                        
                                                 </div><!--timeplace -->
                                                <div class="programbox">
                                                    <h4><?php the_sub_field('program_title'); ?></h4>
                                                     <div class="pdesc"><?php the_sub_field('program_description');?></div>
                                                       
                                                </div><!-- .biobox -->
                                                
                                                <div class="minispeakers">                                            
                                                <?php if( have_rows('program_speakers') ): ?>      
                                                    <ul>
                                                    <?php while ( have_rows('program_speakers') ) : the_row();  ?>
                                                    
                                                        <li class="mini">
                                                            <div class="minipic">
                                                            <img src="<?php the_sub_field('mini_portrait');?>" />
                                                            </div><!-- .companypic -->
                                                            <div class="mininfo">
                                                                <span class="minname"><?php the_sub_field('mini_company_name'); ?></span><br />
                                                                <span class="mincomp"><?php the_sub_field('mini_speaker_name');  the_sub_field('speaker_time'); ?></span>
                                                            </div><!-- .mininfo -->
                                                        </li>
                                                        
                                                    <?php endwhile; ?>  
                                                    </ul>
                                                <?php endif; ?>
                                                </div>
                                                
                                            </li>
             
                                        <?php endwhile; ?>
             
                                </ul>                            
                                <?php endif; ?>  
                                    
                               </div><!-- col-md-12 -->                                     
                        </div><!-- .row -->                                    
                    </div><!-- .container -->
                </div><!-- .fullagenda -->
                </li>                             
         <?php endwhile; ?>
         </ul>                
    <?php endif; ?>
       </div><!-- #fullagenda -->