Hi guys.
I have a repeater field called “gallery”.
And in there i have 2 fields called images_top and images_bottom.
I have then added images in these fields. 3 in each field.
Front-end I am doing this:
<?php if ( have_rows('gallery') ) : ?>
<?php while ( have_rows('gallery')): the_row();
$image = get_sub_field('images_top');
?>
<?php echo $image['url']; ?>
<?php endwhile; ?>
<?php endif; ?>
I have a few divs and UL’s in there, but i did not include that here since that is not the problem.
When i run this code, i get the “dot” from the <li>
tag and no image.
If i just put:
<?php echo $image; ?>
instead of including the [‘url’] at the end i get the text “Array”.
If i var_dump $image i get all the information about link, url, caption, medium size etc.
If i var_dump $image[‘url’] i get the text NULL.
Anyone have any idea why it does nothing?
You have multiple images? Is this a gallery field or an image field? An image field cannot have multiple images as far as I know.
Assuming it is a gallery field it is returning an array of images and you need to loop over the images to show each image.
$images = get_sub_field('images_top');
if ($images) {
foreach ($images as $image) {
echo $image['url'];
}
}