I want to search a checkbox for multiple values.
This page explains how to search for a value, but only one value (red).
https://www.advancedcustomfields.com/resources/checkbox/
$posts = get_posts(array(
'meta_query' => array(
array(
'key' => 'colors',
'value' => 'red',
'compare' => 'LIKE'
)
)
));
How can I search for multiple Values?
This is not working:
$posts = get_posts(array(
'meta_query' => array(
array(
'key' => 'colors',
'value' => array('red', 'green', 'blue'),
'compare' => 'LIKE'
)
)
));
‘compare’ => ‘IN’ is also not working.
$posts = get_posts(array(
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'colors',
'value' => 'red',
'compare' => 'LIKE'
),
array(
'key' => 'colors',
'value' => 'green',
'compare' => 'LIKE'
),
array(
'key' => 'colors',
'value' => 'blue',
'compare' => 'LIKE'
)
)
));