One thumb to gallery with ACF
-
Hi there,
I’m trying to get the one thumbnail to gallery method you’ve described in the FAQs to work with Advanced Custom Fields as opposed to NextGen. It seems like the logic should be the same, but instead of linking to the images contained in the <div class=”fancybox-hidden”> container, it only links to other thumbnails in the list.
Here is my code :
<?php $press_query = new WP_Query( array( 'post_type' => 'tp_press', 'posts_per_page' => 15, ) ); while ( $press_query->have_posts() ) { $press_query->the_post(); $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($press_query->ID), 'full' ); $url = $thumb['0']; $images = get_field('gallery', $press_query->ID); ?> <a href="<?php echo $url; ?>"><?php the_post_thumbnail('thumbnail'); ?></a> <div class="fancybox-hidden"> <?php if( $images ) { foreach( $images as $image ) { ?> <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> <?php } } ?> </div> <?php }??>
Thoughts?
thnx!
-jennyb
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘One thumb to gallery with ACF’ is closed to new replies.