Home › Forums › ACF PRO › How to query posts in multiple select relationship field (serialized array) › Reply To: How to query posts in multiple select relationship field (serialized array)
Try this, use a posts__in
$sites = get_field('site')
if ($sites) {
$args = array(
'post_type' => 'site',
'post_per_page' => -1,
'posts__in' => $sites,
'order_by' => 'post__in'
);
$site_query = new WP_Query($args);
if ($site_query->have_posts()) {
while ($site_query->have_posts()) {
$site_query->the_post();
get_template_part('loop-sites');
}
}
wp_reset_postdata();
}
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.