Home › Forums › General Issues › Trying to display posts related to other posts › Reply To: Trying to display posts related to other posts
get_fieldin this manner you may need to pass two additional parameters according to the docs at http://www.advancedcustomfields.com/resources/relationship/
post_type => 'any'fails, so might be worth a shot with a set array just to test
<?php $ids = get_field('attach_to_client', false, false); $query = new WP_Query(array( 'post_type' => array('post','page'), 'posts_per_page' => 10, 'post__in' => $ids, 'post_status' => 'any', 'orderby' => 'modified', )); ?> <h3><?php get_field( 'clients' ) ?></h3> <?php if ($query->have_posts()) : ?> <ul> <?php while($query->have_posts()) : $query->the_post(); ?> <li><?php the_title(); ?></li> <?php endwhile; ?> </ul> <?php else: ?> <p>Oops, there are no posts.</p> <?php endif; ?>
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!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.