Hello,
I have an image slideshow with multiple images and captions.
Before each image caption, I’m trying to display a counter: the image number and the total number of images, something like: 1/3; 2/3; 3/3. Below is the code I’m using.
The problem is that it is returning all the counts in the all image captions – “1/3 2/3 3/3”, and not only one per image – “1/3”.
Would be thankful for any advice!
<div class="slideshow">
<?php foreach($page->images() as $image): ?>
<ul>
<li>
<figure>
<img src="<?= $image->url() ?>" alt=""></a>
</figure>
<figcaption>
<?php
$count =1;
foreach($page->images() as $image) {
echo $count . "/" . $page->images()->count();$count++;}
?>
<?= $image->caption() ?>
</figcaption>
</li>
</ul>
<?php endforeach ?>
</div>