Support

Account

Home Forums General Issues Thumbnail Gallery with Lightbox Reply To: Thumbnail Gallery with Lightbox

  • Hi @thinkjon

    Here’s a simple example how to get the thumbnail images from the CPT posts:

    <?php
    
    $posts = get_posts(array(
    	'posts_per_page'	=> -1,
    	'post_type'			=> 'custom_post_type_slug'
    ));
    
    if( $posts ): ?>
    	
    	<ul>
    		
    	<?php foreach( $posts as $post ): 
    		
    		setup_postdata( $post )
    		
    		?>
    		<li>
                <?php $image = get_field('thumbnail_field_name'); ?>
    			<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    		</li>
    	
    	<?php endforeach; ?>
    	
    	</ul>
    	
    	<?php wp_reset_postdata(); ?>
    
    <?php endif; ?>

    Where ‘custom_post_type_slug’ is the slug of your CPT and ‘thumbnail_field_name’ is the name of your image custom field. These pages should give you more idea about it: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/ and https://www.advancedcustomfields.com/resources/image/.

    If you want to learn PHP, I recommend you checking this site: http://www.w3schools.com/php/. If you don’t have the time to do it, I suggest you hire a developer to help you out with it, and I’d recommend looking for one on https://studio.envato.com/ or https://www.upwork.com/.

    Hope this helps 🙂