I have the same problem, this is my code, what’s wrong?
<?php $ids = get_field('correla_blog_post'); $query = new WP_Query(array( 'post_type' => get_post_type(), 'posts_per_page' => 1, 'post__in' => $ids )); if( $ids ): ?> <div class="posts-list clearfix"> <?php foreach( $ids as $post): // variable must be called $post (IMPORTANT) ?> <?php setup_postdata($post); ?> <article class="post-item"> <figure><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('t300x200'); ?></a></figure> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <div class="entry-excerpt"><p><?php the_field('riassunto_per_anteprima'); ?></p></div> </article> <?php endforeach; ?> </div> <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?> <?php endif; ?>
If I change ids to $posts in the foreach it show me 1 result but without thumbnail and extra-fields.
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!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 21, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.