Home Forums General Issues Relationship loop not resetting main loop Reply To: Relationship loop not resetting main loop

  • Using the Basic Loop without setup_postdata(); as explained in the Relationship Field documentation ended up working.

    Here is the code:

    <?php $posts = get_field('event_venue'); // Relationship field
     if( $posts ): ?>
     <?php foreach( $posts as $p):  ?>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <?php the_field('venue_address', $p->ID); ?> <?php get_field('venue_city', $p->ID); ?><?php if( get_field('venue_state', $p->ID )): ?>, <?php the_field('venue_state', $p->ID); ?><?php endif; ?> <?php the_field('venue_postcode', $p->ID); ?> <?php the_field('venue_country', $post->ID); ?>
    <?php endforeach; ?>
    <?php endif; // end our custom Loop within the loop ?>

    I guess the question now is why the Basic Loop with setup_postdata(); doesn’t work? In any event my issue is solved!