Home › Forums › Front-end Issues › Displaying a relationship field on a custom post type taxonomy page › Reply To: Displaying a relationship field on a custom post type taxonomy page
Hi @megancm
Just to clarify, this template is looping over $post objects filtered by a taxonomy? If so, then the issue is most likely your setup_postdata($post);
code which can cause many problems during a loop.
To test this, change your code to:
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php
$posts = get_field('store-type');
echo '<pre>';
print_r( $posts );
echo '</pre>';
?>
<?php endwhile; ?>
<?php endif; ?>
This will simply output the relationship data, and the page shoudl work.
Let me know if the page works, then we can go about re writing your loop to not use the setup_postdata($post);
function.
I believe there is a code example on the relationship field dcos regarding how to do this, so you might be able to figure it out before posting back.
Thanks
E
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.