Home › Forums › Add-ons › Repeater Field › Repeater with Foundation Orbit Slider
Hi all, first post after trawling through a number of topics that have got me close but not quite.
I have a site with let’s say a full height carousel (I know). I have a fixed container with left / right nav and a ‘Next Slide’ panel. I’ve managed to get this to work as I need it too, however, I can’t get the code to return the sub field that is relevant to the active slide/row, it just returns the values for all 4 slides/rows. I’m sure this is a simple fix for someone that knows, but I’m stumped at the moment and I seem to be wasting hours trying different things that produce the same result.
Code is as follows:
Sorry, I meant to add..
Any help you could give would be grateful appreciated. Please be gentle 😉
Cheers guys and gals.
Tom
<ul class="orbit-container">
<?php
// check if the repeater field has rows of data
if( have_rows('home_page_slider') ):
$i = 0; // Set the increment variable
// loop through the rows of data
while ( have_rows('home_page_slider') ) : $i++; the_row();
?>
<li class="orbit-slide loading" id="slide-<?php echo $i; ?>">
<div style="background-image: url(<?php if ( the_sub_field('slide_image') ) { echo 'style="background-image: url(' . the_sub_field('slide_image') . ')"'; } ?>)" class="expanded main-welcome" id="bg-n">
<div class="orbit-upper-content <?php the_sub_field('slider_color_scheme'); ?>">
<h2><?php the_sub_field('slide_title'); ?> <span><?php the_sub_field('slide_title_highlight'); ?></span></h2>
<?php the_sub_field('slide_text'); ?>
<?php
// check if the repeater field has rows of data
if( have_rows('link_buttons') ):
// loop through the rows of data
while ( have_rows('link_buttons') ) : the_row();
?>
<a href="<?php the_sub_field('button_page_link'); ?>" class="button ghost-button-home <?php the_sub_field('button_color'); ?>"><?php the_sub_field('button_label'); ?></a>
<?php
endwhile;
else :
// no rows found
endif;
?>
</div>
</div>
</li>
<?php
endwhile;
else :
// no rows found
endif;
?>
<div class="slide-info">
<div class="direction-buttons">
<button class="orbit-previous"><span class="show-for-sr">Previous Slide</span><i class="fal fa-chevron-left"></i></button>
<button class="orbit-next"><span class="show-for-sr">Next Slide</span><i class="fal fa-chevron-right"></i></button>
</div>
<span>Next Slide</span>
<?php
$i = 0;
while(has_sub_field('home_page_slider')):
echo '<div id="slide-' . $i . '"><h4>' . get_sub_field('next_slide') . '</h4></div>';
$i++;
endwhile;
?>
<p>Find out more...</p>
</div>
</ul>
Can’t tell by your description or your code exactly what part you’re having problems with. Comment your code or explain more precisely where in your code things are going wrong.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.