Support

Account

Home Forums General Issues How to create meta_query with relationship field and comparator 'IN'? Reply To: How to create meta_query with relationship field and comparator 'IN'?

  • You cannot to an “IN” query on a relationship field.

    see section 3 of this doc https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

    You need to do

    
    $meta_query = array(
      'relation' => 'OR',
      array(
        'key' => 'field_name',
        'value' => '"'.$first_id.'"',
        'compare' => 'LIKE'
      ),
      array(
        'key' => 'field_name',
        'value' => '"'.$second_id.'"',
        'compare' => 'LIKE'
      ),
      // etc.. 
    );