Home › Forums › ACF PRO › How to use repeater fields for bootstrap carousel? › Reply To: How to use repeater fields for bootstrap carousel?
hi, i think the main part should look like this
<?php $carousel = get_field('carousel');
if($carousel):
while( have_rows('carousel') ): the_row();
$slider_image = "";
$slide_headline = "";
$sub_headline = "";
$button_url = "";
$button_text = "";
$slider_image = get_sub_field('slider_image');
$slide_headline = get_sub_field('slide_headline');
$sub_headline = get_sub_field('sub_headline');
$button_url = get_sub_field('button_url');
$button_text = get_sub_field('button_text');
?>
<div class="item slides">
<div class="cslide" style="background: url(<?php echo $slider_image; ?>)"></div>
<div class="hero">
<hgroup>
<h1><?php echo $slide_headline; ?></h1>
<h3><?php echo $sub_headline; ?></h3>
</hgroup>
<a href="<?php echo $button_url; ?>"><button class="btn btn-hero btn-lg" role="button"><?php echo $button_text; ?></button></a>
</div>
</div>
<?php endwhile; endif;?>
hope that help.
depends on what is required, and what your image output is, you may need to adjust your code. here a sample how to make a optional field and get image when use array
<php? if($my_teaserimage){
echo '<div class="teaserimage"><img src="'. $my_teaserimage['url'] .'" /></div>';
} ?>
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!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 7, 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.