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
here is some code to test that the post_id is correct:
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while (have_posts()) : the_post();
$post_id = get_the_ID();
?>
<h2>Title: <?php the_title(); ?></h2>
ID: <?php echo $post_id; ?>
ACF without ID
<?php
echo '<pre>';
print_r( get_field('store-type', false, false) );
echo '</pre>';
?>
ACF with ID
<?php
echo '<pre>';
print_r( get_field('store-type', $post_id, false) );
echo '</pre>';
?>
<?php endwhile; ?>
<?php endif; ?>
Please use this code and check that the post_id displayed are the ones you are expecting
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.