Support

Account

Home Forums Front-end Issues Sort by repeater in a repeater

Unread

Sort by repeater in a repeater

  • I have a repeater within a repeater and want to order the second repeater by name.

    Below is my code, I’ve tried looking at the guide but not getting far;

    <?php while ( have_posts() ) : the_post(); ?>
    	<?php 
    		// check for rows (parent repeater)
    		if( have_rows('things_to_do') ): 
    		$i=1;
    	?>							
    		<?php 
    			while( have_rows('things_to_do') ): the_row(); 
    		?>										
    			<div class="list_shell" id="<?php the_sub_field('section_id'); ?>">
    				<h2><?php the_sub_field('section_title'); ?></h2>
    
    				<div class="flex-wrapper list_wrapper">
    					<?php 
    						if( have_rows('section_list') ): ?>										
    							<?php 
    								while( have_rows('section_list') ): the_row();
    							?>										
    								<div class="flex-shell list_item">
    									<div class="flex-item">
    										<div class="list_block">
    											<div class="description_image">
    												<?php if ( get_sub_field( 'image' ) ): ?>
    													<img src="<?php the_sub_field('image'); ?>" alt="<?php the_sub_field('name'); ?>">	
    												<?php else: ?>
    													<img src="<?php echo get_template_directory_uri(); ?>/images/temp-image.jpg" alt="<?php the_sub_field('name'); ?>">
    												<?php endif; ?>
    											</div>
    											<div class="description_copy">
    												<h3 class="blue"><?php the_sub_field('name'); ?></h3>
    
    												<?php the_sub_field('description'); ?>
    
    												<?php if ( get_sub_field( 'website_url' ) ): ?>
    													<a href="<?php the_sub_field('website_url'); ?>" class="btn blue smaller" target="_blank">Visit their website</a>	
    												<?php else: ?>
    													
    												<?php endif; ?>
    												
    											</div>
    										</div>
    									</div>
    								</div>
    						<?php endwhile; ?>									
    					<?php endif; ?>	
    				</div>
    			</div>												
    		<?php 
    			$i++;
    			endwhile; 
    		?>
    		<?php wp_reset_query(); ?>
    	<?php endif; ?>
    	<?php wp_reset_query(); ?>
    <?php endwhile; ?>
Viewing 1 post (of 1 total)

The topic ‘Sort by repeater in a repeater’ is closed to new replies.