So I have 8 checkboxes: A,B,C,D,E,F,G,H for example. All of them have the same name, and I need to get their values as an array in meta_query. I hope code can explain better than I do :)
$args = array(
'post_type'=>'paibcresume',
'posts_per_page' => 10,
'paged' => $paged,
'meta_query' => array(),
'tax_query' => array(),
'orderby' => 'date',
'meta_key' => '',
'order' => 'DESC'
);
// Search by occupation
//rbwwbusy - custom field
//rbseroccupation - search checkbox fields
if (isset($_GET['rbseroccupation']) && !empty($_GET['rbseroccupation'])) {
$args['meta_query'][] = array(
'key' => 'rbwwbusy',
'value' => array($_GET['rbseroccupation']),
'compare' => 'IN'
);
}
<div class="occupation">
Occupation:<br>
<input type="checkbox" name="rbseroccupation" value="A"> A
<input type="checkbox" name="rbseroccupation" value="B"> B
<input type="checkbox" name="rbseroccupation" value="C"> C
<input type="checkbox" name="rbseroccupation" value="D"> D<br>
<input type="checkbox" name="rbseroccupation" value="E"> E
<input type="checkbox" name="rbseroccupation" value="F"> F
<input type="checkbox" name="rbseroccupation" value="G"> G
<input type="checkbox" name="rbseroccupation" value="H"> H
</div>
So my question is: it works, but it only displays results for the last checked checkbox. So for example if i look for A and B, it only displays B; if I look for A, B and C it only display posts with C.
What do I need to do, so it shows for example posts with A,B and C, not only the last checked?
Thank you!