I have a list of category children in a form, I am hoping to have the user select all the subcategories they want to include in their search results. Once the user hits submit, they would be taken to another page with the results.
<form>
<?php
$args = array(
'taxonomy' => 'category',
'parent' => 0, // get top level categories
'orderby' => 'name',
'order' => 'ASC',
'hierarchical' => 1,
'pad_counts' => 0
);
$categories = get_categories( $args );
foreach ( $categories as $category ){
echo '<div class="search-box">';
echo '<div class="search-box-inside">';
echo '<h4>'. $category->name . '</h4>';
$sub_args = array(
'taxonomy' => 'category',
'parent' => $category->term_id, // get child categories
'orderby' => 'name',
'order' => 'ASC',
'hierarchical' => 1,
'pad_counts' => 0
);
$sub_categories = get_categories( $sub_args );
foreach ( $sub_categories as $sub_category ){
echo '<label><input type="checkbox" id="type-'. $sub_category->name . '" rel="'. $sub_category->name . '">'. $sub_category->name . '</label>';
}
echo '</div>';
echo '</div>';
}
?>
<input type="submit" value="Submit">
</form>
So far I am able to echo a list of the subcategories with checkboxes, but how do I feed the checkbox values into a searchable query so I can get all the subcategories that were selected?