Home › Forums › Add-ons › Repeater Field › Previous and next field in repeater › Reply To: Previous and next field in repeater
Hi @gummi thanks for taking the time to help. I still don’t quite understand 100%. My code so far is below.
Ideally, Im looking to pull in the previous and next title field in my loop, a long with the current loop title.
<?php
$blocks = get_field('fbs');
if( $blocks ) :
$count = 1;
?>
<div id="fullpage">
<?php foreach( $blocks as $block ) :
// ACF Vars
$image = $block['fb_main_image'];
$imagePos = $block['fb_main_image_fp'];
$title = $block['fb_title'];
$text = $block['fb_text'];
$link = $block['fb_link'];
$linkText = $block['fb_link_text'];
?>
<div class="section" data-anchor="section-<?php echo $count; ?>" style="background-image: url(<?php echo $image['url']; ?>);">
<section class="o-block">
<div class="o-container o-container--top">
<h2 class="o-type-60 u-mb-x4 u-colour-white">GET PREVIOUS TITLE HERE</h2>
</div>
<div class="o-container">
<h2 class="o-type-100 u-mb-x4 u-colour-white"><?php echo $title; // Current Title?></h2>
</div>
<div class="o-container">
<h2 class="o-type-100 u-mb-x4 u-colour-white">GET NEXT TITLE</h2>
</div>
</section>
<!-- .o-block -->
</div>
<!-- .section -->
<?php $count++; endforeach; ?>
</div>
<!-- #fullpage -->
<?php endif; ?>
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!
The most recent ACF Chat Friday featured a live demo of how to register CPTs directly in the plugin, one of our most requested features. Check out the summary below for a replay of the demo, and don’t forget to register for the next session! https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 9, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.