My query works with radio but not checkboxes. I’m using a basic query format for facetWP to filter all posts with a type “Program” to see if the custom field drptest = “Educational”. It looks like this:
<?php
$my_acf_checkbox_field_array = get_field('drptest');
return [
"post_type" => [
"programs"
],
"post_status" => [
"publish"
],
"meta_query" => [
[
"key" => "drptest",
"compare" => "IN",
"type" => "CHAR",
"value" => [
"Educational"
]
]
],
"orderby" => [
"date" => "ASC"
],
"posts_per_page" => "15"
];
This works with a field as radio select… What would I have to do to make it function with checkboxes?
Thanks in advance.
A checkbox field stores a serialized array in the DB.
// to search for one of 2 values
<code>meta_query</code> => array(
'relation' => 'OR',
array(
'key' => 'drptest',
'value' => 'Educational',
'compare' => 'LIKE'
),
array(
'key' => 'drptest',
'value' => 'some other value',
'compare' => 'LIKE'
)
)