Home › Forums › ACF PRO › Put styles to file with unique ID › Reply To: Put styles to file with unique ID
Maybe I could use an easier method. Like this (extra while loop with $i++) to get unique classes:
<?php if( have_rows('_post_slider') ) : ?>
<?php $flexibleSlider = 0 ?>
<?php while( have_rows('_post_slider') ) : the_row(); ?>
<?php $flexibleSlider++; ?>
<?php endwhile; ?>
<div class="row slider-wrapper">
<div class="col-md-12">
<div class="slider_inner slider-<?php echo $flexibleSlider; ?> ">
<?php
$count_dataindex = 0;
$count_dataid = 0;
?>
<?php while( have_rows('_post_slider') ) : the_row(); ?>
<?php $count_dataindex++; ?>
<article class="" data-index="<?php echo $count_dataindex; ?>" data-slidertitle="<?php the_sub_field('_headline'); ?>">
<?php $image = get_sub_field('_bild'); ?>
<figure style="background-image: url(<?php echo $image['sizes']['img-l']; ?>)"></figure>
<?php if ( get_sub_field('_headline') ) : ?>
<div class="slider-headline" data-id="<?php echo $count_dataid; ?>">
<?php echo get_sub_field('_headline'); ?>
</div>
<?php endif; ?>
</article>
<?php endwhile; ?>
</div>
</div>
</div>
<script>
jQuery(document).ready(function($){
$('.slider-<?php echo $flexibleSlider; ?> ').slick({
infinite: true,
slidesToShow: 1,
slidesToScroll: 1
});
});
</script>
<?php endif; ?>
EDIT: Hm no. I get “slider-4”, “slider-3”, “slider-3” … .
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!
🚀 ACF & ACF PRO 6.0.7 are now available.
— Advanced Custom Fields (@wp_acf) January 18, 2023
✨This release contains bug fixes and improvements while we continue to work on the next major release of ACF.https://t.co/wQgAOpwmUI
© 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.