Okay, so I see there is this — http://www.advancedcustomfields.com/resources/filters/acf-fields-relationship-query/
But I wish there was an example of it in use, not just in the functions.php. I’m still not sure how to actually use it in my case.
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!
It actually fails after the first relationship field (“research centers”) so then the second relationship field (“presenters”) also doesn’t display.
I had considered doing what you suggest… but I figured it would be better if I could just reset things properly. 🙂
Thank you for looking… if you have any other ideas, let me know.
Absolutely! Here is a gist link: https://gist.github.com/relish27/22772e2381b2aeb12b89
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.