Support

Account

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();
    }