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)

  • Sorry, my mistake, it should be post__in, typo, I made it plural

    
    $sites = get_field('site')
    if ($sites) {
        $args = array(
            'post_type' => 'site',
            'post_per_page' => -1,
            'post__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();
    }