Support

Account

Home Forums Add-ons Repeater Field Reusing content from another repeater

Unread

Reusing content from another repeater

  • Hi

    I’m using a section which has two repeater fields in. Is there a way to reuse content from one repeater in the other?

    https://www.dropbox.com/scl/fi/5wysy9y3z41rhdcvjol9r/Screenshot-2024-01-03-at-20.57.32.png?rlkey=t13cmgxnklh6wwzqtki27rcpb&dl=0

    I reuse bits using the page ID, but haven’t done it before between repeaters. Is this possible?

    
    
    // CASE: Team Blocks
    					elseif( get_row_layout() == 'team_blocks_section' ): ?>
    
    					<section id="team-carousel" class="<?php the_sub_field('section_colour'); ?> <?php the_sub_field('section_spacing'); ?> <?php the_sub_field('section_padding'); ?>">
    							<div class="container">
    								<div class="row">
    									<div class="section-centre centred-section">
    										<h2><?php the_sub_field('heading'); ?></h2>
    										<?php if( get_sub_field('text') ): ?>
    											<p><?php the_sub_field('text'); ?></p>
    										<?php endif; ?>
    									</div>
    								</div><!--row-->
    
    								<div class="row">
    									<?php // check if the repeater field has rows of data
    									if( have_rows('team_members') ):
    										 // loop through the rows of data
    										while ( have_rows('team_members') ) : the_row(); ?>
    
    								  <div class="col-lg-4 justify-content-center">
    									<div class="card text-center">
    										<?php
    										$image = get_sub_field('image');
    										$size = 'full'; // (thumbnail, medium, large, full or custom size)
    										if( $image ) {
    											echo wp_get_attachment_image( $image, $size );
    										} ?>
    										<div class="card-body d-flex flex-column">
    											<h4><?php the_sub_field('name'); ?></h4>
    											<h5><?php the_sub_field('job_title'); ?></h5>
    											<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#<?php the_sub_field('popup_link'); ?>">
    											 Read bio
    											</button>
    											<div class="mt-auto card-linkedin text-center">
    												<a href="<?php the_sub_field('tm_linkedin'); ?>"><img  src="<?= get_template_directory_uri(); ?>/images/LI-In-Bug.png" alt="LinkedIn"  /></a>
    											</div>
    										</div>
    									</div>
    								  </div>
    								  <?php
    									  endwhile;
    								  else :
    									  // no rows found
    								  endif;
    								  ?>
    
    								</div>
    
    								<?php // check if the repeater field has rows of data
    								if( have_rows('team_members_popup') ):
    									 // loop through the rows of data
    									while ( have_rows('team_members_popup') ) : the_row(); ?>
    								<!-- Modal -->
    								<div class="modal fade" id="<?php the_sub_field('popup_name'); ?>" tabindex="-1" role="dialog" aria-labelledby="<?php the_sub_field('popup_name'); ?>Label" aria-hidden="true">
    								  <div class="modal-dialog" role="document">
    									<div class="modal-content">
    									  <div class="modal-header">
    
    										<button type="button" class="close" data-dismiss="modal" aria-label="Close">
    										  <span aria-hidden="true">×</span>
    										</button>
    									  </div>
    									  <div class="modal-body">
    										<?php
    										$image = get_sub_field('image');
    										$size = 'full'; // (thumbnail, medium, large, full or custom size)
    										if( $image ) {
    											echo wp_get_attachment_image( $image, $size );
    										} ?>
    										<h4><?php get_sub_field('name'); ?></h4>
    										<h5><?php get_sub_field('job_title'); ?></h5>
    										<p><?php the_sub_field('tm_text'); ?></p>
    									  </div>
    
    									</div>
    								  </div>
    								</div>
    								<?php
    									  endwhile;
    								  else :
    									  // no rows found
    								  endif;
    								  ?>
    
    </section>
    
    
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.