Home › Forums › Front-end Issues › Multiple ID's in relationship field — LIKE query returns inappropriate posts › Reply To: Multiple ID's in relationship field — LIKE query returns inappropriate posts
It shouldn’t match both 2
and 127
because it has extra double quotes there:
'"' . get_the_ID() . '"'
For example, if get_the_ID()
returns 2
, then the query would be like this:
'value' => '"2"',
Which will only match serialized string that has "2"
in it like this:
a:1:{i:0;s:1:"2";}
And not this one:
a:1:{i:0;s:3:"127";}
Could you please test it again by providing the value manually like this:
'meta_query' => array(
array(
'key' => 'location',
'value' => '"2"',
'compare' => 'LIKE'
)
),
Also, could you please check the database if there’s extra ID there?
Thanks 🙂
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.