Home › Forums › Pre-purchase Questions › Gallery add-on › Reply To: Gallery add-on
Thank you and sorry for taking so long to answer.
Unfortunately it seems like this isn’t working either. It’s not taking the correct images from the gallery field and shows only the featured image of the post. This is the code I used:
<?php
$images = get_field('MYFIELDNAME');
$image_ids = array();
$max = 5;
$i = 0;
if( $images )
{
foreach( $images as $image )
{
$i++;
if( $i > $max){ break; }
$ids[] = $image['id'];
}
}
$shortcode = '[gallery columns="1" link="file" size="medium" ids="' . implode(',', $image_ids) . '"]';
echo do_shortcode( $shortcode );
?>
Is there something I’m doing wrong? Any other data I should change in addition to the field name after “get_field”?
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.