Home › Forums › ACF PRO › Multiple Repeater fields on single page wont work › Reply To: Multiple Repeater fields on single page wont work
Okay so i stumbled upon this solution by accident but it works for me so maybe it works for you as well.
I use the code of @jorgecastellonjr for my explanation.
This is his original code:
<div class="top__wrap">
<?php if ( have_rows( 'top_item' ) ):
while( have_rows('top_item') ): the_row();
$value = get_sub_field( 'value' );
?>
<div class="top__item"><?php echo $value ?></div>
<?php endwhile; endif;?>
</div>
<div class="bottom__wrap">
<?php if ( have_rows( 'bottom_item' ) ):
$symbol = get_sub_field( 'symbol' );
?>
<div class="bottom__wrapper">
<div class="bottom__item"><?php echo $symbol ?></div>
</div>
<?php endwhile; endif; ?>
</div>
The only thing you have to do is to add the following code before your if-statement for the second repeater:
<?php have_rows( 'bottom_item' ) ): ?>
And the code will look like this:
<div class="top__wrap">
<?php if ( have_rows( 'top_item' ) ):
while( have_rows('top_item') ): the_row();
$value = get_sub_field( 'value' );
?>
<div class="top__item"><?php echo $value ?></div>
<?php endwhile; endif;?>
</div>
<div class="bottom__wrap">
<?php ( have_rows( 'bottom_item' ) ): ?>
<?php if ( have_rows( 'bottom_item' ) ):
$symbol = get_sub_field( 'symbol' );
?>
<div class="bottom__wrapper">
<div class="bottom__item"><?php echo $symbol ?></div>
</div>
<?php endwhile; endif; ?>
</div>
I hope this works for you guys as well!
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.