My Query arguments;
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'partner',
'value' => $partner,
'compare' => 'LIKE',
),
),
);
If my value for $partner="561"
this query also returns Posts where $partner="5614"
Setting 'compare' => '='
or 'compare' =>'INCLUDE'
returns nothing.
Where is my misunderstanding?
Note that due to the vagaries of ACF ‘value’ could either be an array or a string. And this also successfully returns a post where $partner= array("561","21423")
at the moment I am testing the results with if ( in_array($partner, get_field('partner')) )
but that’s clumsy.
2
Answers
NOT TESTED, but doesn’t it about the field type ?
In meta_query the default value of type is ‘CHAR’
(Doc: https://developer.wordpress.org/reference/classes/wp_meta_query/#usage)
And by extension, maybe the comparison is not strict.
I think your problem may be stemming from the instances where ‘value’ is an array. From the docs:
https://developer.wordpress.org/reference/classes/wp_meta_query/#accepted-arguments