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): ?>
<td>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</td>
<td>
<?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); ?>
</td>
<?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!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.