IN works quite fine for comparison though
array(
'key' => 'customdata',
'value' => $arraydata,
'compare' => 'IN'
),
but when i try below with LIKE it returns strange result with long codes and also no record is found against it. Any help much appreicated
array(
'key' => 'customdata',
'value' => $arraydata,
'compare' => 'LIKE'
)
$loop = new WP_Query($loopArray);
echo "Query: {$loop->request}";
$arraydata
?LIKE
is used to compare strings. What values are you hoping to match with an array by usingLIKE
? Do you want to checkLIKE
for each element in the array?%
. See: wordpress.stackexchange.com/questions/303935/…IN
is for checking if a value is in an array.LIKE
is for comparing strings. They are for different things. You can't just use them interchangeably. You've ignored my question: What is inside the$arraydata
variable? Is it a string, or an array?for
loop on this array to create multiple LIKE conditions for each possible value and combine them in meta_query array withrelation => 'OR'
. See wordpress.stackexchange.com/questions/104060/… for combined meta_query example.