Home › Forums › Add-ons › Gallery Field › Gallery plugin does not return array › Reply To: Gallery plugin does not return array
Im still having this exact problem even with this “solution”
<?php
$gallery = get_sub_field('gallery', 'option');
foreach($gallery as $photo):?>
<a href="<?php echo $photo['url']; ?>" class="cbox item">
<img src="<?php echo $photo['sizes']['thumbnail']; ?>"/>
</a>
<?php endforeach;?>
The name of the field is gallery.
additionally I tried to pass in the post id into the second param :
<?php
$postid = get_the_ID();
$gallery = get_sub_field('gallery', $postid);
foreach($gallery as $photos): ?>
<a href="<?php echo $photos['url']; ?>" class="cbox item">
<img src="<?php echo $photos['sizes']['thumbnail']; ?>"/>
</a>
<?php endforeach;?>
Any thoughts sir ?
when I var dump the $gallery obj it returns bool
php errors are the same “Invalid value in foreach”
UPDATE:
I just reverted our ACF plugins back to 4.2.2 and it works now.
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!
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.