Support

Account

Home Forums General Issues Relationship Gallery issue Reply To: Relationship Gallery issue

  • Hey Elliot,
    Sorry, I simplified that to make it easy to understand (but prob made it more confusing :B ). Here’s my full code:

    <?php
    	$args = array ( 'post_type' => 'school-category');             
    	$loop = new WP_Query( $args );
    	while ( $loop->have_posts() ) : $loop->the_post();
    ?>
    
    <div>
    
    <?php 
    
    	/* films is a realtionship ACF field */
    	$films = get_field('films');
    		
    	if( $films ): ?>
    	
    		<div class="image_data">
    		
    			<?php foreach( $films as $post): ?>
    				
    				<?php setup_postdata($post); ?>
    											
    				<?php if ( get_field('running_time') ) :
    					the_field('running_time');
    				endif; ?>
    				
    											
    				<?php if ( get_field('images') ) :
    					$images = get_field('images'); ?>
    					<img src="<?php echo $images[0]['url']; ?>" alt="<?php the_title(); ?>">
    				<?php endif; ?>
    									
    			<?php endforeach; ?>
    			
    		</div>
    		
    		<?php wp_reset_postdata(); ?>
    	
    	<?php endif; ?>
    
    </div>
    				
    <?php endwhile; ?>

    The issue is that the if (get_fields(‘images’)) returns a false, where as all over the rest of the site it returns true. I dumped all the post’s custom fields and could see that images was an empty array, where all the ACF fields returned their values.

    Any ideas? Thanks Elliot!