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.

    $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 class="o-container">
    			<h2 class="o-type-100 u-mb-x4 u-colour-white"><?php echo $title; // Current Title?></h2>
    <div class="o-container">
    			<h2 class="o-type-100 u-mb-x4 u-colour-white">GET NEXT TITLE</h2>
    						<!-- .o-block -->
    					<!-- .section -->
    					<?php $count++; endforeach; ?>
    				<!-- #fullpage -->
    				<?php endif; ?>