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;
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.