I have a field where users can upload 3 images to the gallery to be used in a slider.
Right now, only the last image in the gallery array is displaying.
Here’s some code.
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$show = get_field('show_information');
if ($show) : ?>
<div class="swiper-container js-swiper">
<div class="swiper-wrapper">
<?php
$images = $show['media'];
if ($images) : ?>
<div class="swiper-slide px-4 h-auto">
<?php foreach ($images as $image) : ?>
<div class="prlx bg-dark bg-cover swiper-lazy" data-background="<?php echo $image['url']; ?>">
<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div>
</div>
<?php endforeach; ?>
<div class="container py-4 py-md-5">
<div class="row">
<div class="col-12" style="height:450px">
</div>
</div>
</div>
</div>
<?php endif; ?>
...
I have a feeling I am not targeting the array correctly, but it could be the loop. Not sure where to go from here.
Do I need to include another arg with $images = $show['media']{something here?};
?
@adam_g is show_information
a group field and media
is a gallery field inside the group? That’s the only reason I can think of why you would have $images = $show['media'];
Have you inspected the element or view source of the page to see if all the images are being added in the page’s rendered HTML?