Home › Forums › Add-ons › Repeater Field › 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?
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>
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.