Hello
I created a checkbox custom field in ACF, it has many values. Users can select one check box or many
in my wordpress query if wont match results if multiple checkboxes are selected unless the custom post has those exact checkboxes checked (but will if only one is checked)… this will make it almost impossible for users to get search results, so i want the checkboxes to be OR in my meta_query instead of AND
this is my code so far. (I created a loop to grab all individual values and add them to query if needed)
$field = get_field_object('field_5ecec6646a47a'); // field key of your field
if (!empty($field['choices'])) {
foreach ($field['choices'] as $v => $l) {
if (isset( $_GET["yoga_focus-".$v.""] ) && ($_GET["yoga_focus-".$v.""] != "") ) {
$args['meta_query'][] = array('relation' => 'OR', array('key' => 'focus', 'value' => $_GET["yoga_focus-".$v.""], 'compare' => 'LIKE'));
}
}}
$args['meta_query'] = array('relation' => 'OR', array('key' => 'focus', 'value' => $_GET["yoga_focus-".$v.""], 'compare' => 'LIKE'));