Hi!
I’m using repeater field to add images to carousel.
How can I get number of all images added in certain page throug repeater field ?
This is my code:
<?php $count_images = 1; ?>
<div class="gallery">
<?php while ( have_rows('gallery') ) : the_row(); ?>
<?php
$image = get_sub_field('gallery_image');
$size = 'gallery';
?>
<div class="one-third">
<?php if( $image ) { ?>
<?php
echo wp_get_attachment_image( $image, $size );
echo $count_images;
?>
<?php } ?>
</div>
<?php if( $count_images % 3 == 0 ) { ?>
</div>
<div class="gallery">
<?php } ?>
<?php $count_images++ ?>
<?php endwhile; ?>
</div>
the number of images should be the number of rows from your repeater field.
that means you can get it like that:
<?php if( have_rows('gallery') ):
$gallery_rows= get_field('gallery');
$total_images = count($gallery_rows);
endif; ?>
Thank you mediawerk…this was the part I needed 🙂