Home › Forums › General Issues › Trouble with resetting › Reply To: Trouble with resetting
Ah-ah, I found a workaround. I just noticed now that the ACF relationship docs have a second option that doesn’t set postdata: http://www.advancedcustomfields.com/resources/field-types/relationship/
/*
* Loop through post objects ( don't setup postdata )
* Using this method, the $post object is never changed so all functions need a seccond parameter of the post ID in question.
*/
$posts = get_field('relationship');
if( $posts ): ?>
<ul>
<?php foreach( $posts as $post_object): ?>
<li>
<a href="<?php echo get_permalink($post_object->ID); ?>"><?php echo get_the_title($post_object->ID); ?></a>
<span>Post Object Custom Field: <?php the_field('field_name', $post_object->ID); ?></span>
</li>
<?php endforeach; ?>
</ul>
<?php endif;
This helps me avoid the situation!
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.