Support

Account

Home Forums General Issues get_users with array value for meta_query value in Reply To: get_users with array value for meta_query value in

  • First thing is that an ACF post object field does not store the name of the related post. It stores the post ID of that post. So if you are searching the post object field you need to use post IDs and not names.

    Second, because you have the post object field set to allow multiple selections ACF stores those selections as a serialized array in a single row of the database. This array cannot be search the same way as a standard WP custom field.

    https://www.advancedcustomfields.com/resources/querying-relationship-fields/

    
    $meta_query = array('relation' => 'OR');
    foreach ($companies as $post_id) {
      $meta_query(
        'key' => 'company',
        'value' => '"'.$post_id.'"'.
        'compare' => 'LIKE'
      }
    }
    $args['meta_query'] = $meta_query;