Home › Forums › Add-ons › Gallery Field › Gallery Code Not Working
$images = get_field('gallery');
if( $images ): ?>
<?php foreach( $images as $image ): ?>
<a href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php echo $image['caption']; ?>
<?php endforeach; ?>
<?php endif; ?>
I am using the above code in X theme but nothing shows up in my posts. Any ideas as to why?
This code works:
$image_ids = get_field('gallery', false, false);
$shortcode = '[gallery ids="' . implode(',', $image_ids) . '"]';
echo do_shortcode( $shortcode );
but the images are unformatted and not linked to large versions of the images.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Open a new forum thread
Helping others is a great way to earn karma, gain badges and help ACF development!
Performance: Switching to post_author to store order customer IDs https://t.co/gS59xxQrjH pic.twitter.com/2S4M0UHIEU— WooCommerce (@WooCommerce) January 15, 2018
Performance: Switching to post_author to store order customer IDs https://t.co/gS59xxQrjH pic.twitter.com/2S4M0UHIEU
© 2018 Advanced Custom Fields. Terms & Conditions. Subscribe