Reputation: 1998
I am trying to use the following method to filter the category id on my mini form submit
<input type="hidden" name="cat" value="1">
But this only allows to filter by 1 category id, I need to be able to pass in an array of category ID's to the mini form. Is there anyway I can use a similar method to filter the search results by an array of category id's? Or can anyone point me in the right direction on how to achieve this?
Upvotes: 0
Views: 157
Reputation: 46
You can use serialize() and base64_encode().
$cat_ids = array(1, 2, 3);
$post_cat_ids = base64_encode(serialize($cat_ids));
// Input field
<input type="hidden" name="cat" value="<?php echo $post_cat_ids; ?>">
On server side you can get back array:
$cat_ids = unserialize(base64_decode($_POST['cat']));
print_r($cat_ids);
Upvotes: 2