JSFiddle - React, Tailwind, and code Playground
HTML
//the selectbuild edition
if($tax == 'restaurants-features'){
$x = '<div name ="'. $tax .'" class="checkbox-filters">';
foreach ($terms as $term) {
$checked = '';
if ( in_array( $term->slug, 'restaurants-features' ) ) {
$checked = 'checked';
}
$x .= '<div class="col-sm-6"><input class="hidden-checkbox" type="checkbox" name ="' . $tax . '[]" value="' . $term->slug . '" ' . $checked . ' /><span> ' . $term->name . '</span></div>';
}
$x .= '</div>';
//the query edition
foreach($_POST as $key => $value){
if($value != ''){
$item['taxonomy'] = htmlspecialchars($key);
if($key == 'restaurants-features'){
foreach($value as $v) {
$item['terms'][] = htmlspecialchars($v);
}
}
$item['terms'] = $value;
$item['field'] = 'slug';
$list[] = $item;
}
}