Support

Account

Home Forums General Issues Query with Relationship field Reply To: Query with Relationship field

  • Hi @mclambert

    I’m afraid you need to use multiple ‘meta_query’ values like this:

    $meta_query = array('relation' => 'AND');
    foreach( $offres_id as $the_id ) {
        $meta_query[] = array(
            'key' => 'offre_liee', 
            'value' => '"' . $the_id . '"', 
            'compare' => 'LIKE'
        );
    }

    Then you can use it like this:

    'meta_query' => $meta_query,

    This will create the query for all of the IDs you get. Unfortunately, I’m not sure regarding the performance if you have a lot of IDs.

    I hope this helps 🙂