Home › Forums › Front-end Issues › Relationship Field Empty › Reply To: Relationship Field Empty
FIXED! A friend help me. Here’s an update.
<?php if( $ids = get_field('featured_posts', 'options', false, false) ) :
$query = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 5,
'post__in' => $ids,
'post_status' => 'publish',
));
if ( $query->have_posts() ) : ?>
<div class="">
<ul class="slides">
<?php while ( $query->have_posts() ) : $query->the_post(); // variable must NOT be called $post (IMPORTANT) ?>
<li>Loop here</li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
</div>
<div class="fix"></div>
<?php else : ?>
<?php endif; 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!
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.