Support

Account

Home Forums Add-ons Gallery Field Include Gallery Field in Custom Post Type Reply To: Include Gallery Field in Custom Post Type

  • Hi @theatereleven

    I have taken your code and inserted the code example from the gallery page. Hope this helps:

    
    <?php
    
    	 $loop = new WP_Query( array( 'post_type' => 'cars', 'posts_per_page' => 10 ) );
    	 while ( $loop->have_posts() ) : $loop->the_post();
    		
    		$images = get_field('gallery');
    		 
    		if( $images ): ?>
    		    <div id="slider" class="flexslider">
    		        <ul class="slides">
    		            <?php foreach( $images as $image ): ?>
    		                <li>
    		                    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    		                    <p><?php echo $image['caption']; ?></p>
    		                </li>
    		            <?php endforeach; ?>
    		        </ul>
    		    </div>
    		    <?php
    		
    		
    	   endwhile;
    
    	?>
    

    Thanks
    E