Support

Account

Home Forums Front-end Issues Relationship is not working on front page Reply To: Relationship is not working on front page

  • 
    <?php
    
    	$posts = get_field(‘major_city’);
    
    if( $posts ): ?>
    
        <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
        <?php setup_postdata($post); ?>
    
       <?php the_title(); ?>
        <span>Custom field from $post: <?php
            the_post_thumbnail();
    
        ?></span>
    
        <?php endforeach; ?> 
    
    <?php wp_reset_postdata(); // IMPORTANT – reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>