However, we wanted to dynamically search only the subcategories of the Recipe Category. The reason being that if you’re already in the Recipes section of the site, seeing a recipe labeled as Recipes is not helpful. However, seeing a recipe labeled as Dessert (mmm..) and Breakfast is helpful. So, each recipe that the client adds will be in a subcategory of recipes (ex. Dessert), but they won’t have to check off the checkbox next to the Recipes category itself.

Anyway, I’ve been looking for this solution for a long time and now, thanks to Ilan Cohen, I present it to you.

The code searches through all the child categories of Category 5 (Recipes). Then, you’ll see we added an additional “5” in this line: $catlist.’5′; just in case the client puts a recipe in the Recipes category, and not one of its subcategories.

Share:

Rebecca Markowitz has built over 50 WordPress sites for clients as Web Project Manager and WordPress specialist at illuminea. illuminea is a Jerusalem-based boutique web agency. WPGarage shows my dedicated relationship with WordPress over the years - full of love, laughs, tears, growth and strong drinks. L'chaim!

Hi,
Thanks for Sharing,
I tried the multiple categories search and all I did was copy/paste the code above in my index page replacing “5” with cat”3″.
I had an error message saying there was something wrong on line:

I know its a little late but you can use this code with Search unleashed, all you need to do is change the word ‘cat’ to ‘post_category’ since search unleashed describes categories as ‘post_categories’ and wordpress search uses ‘cat’.
So any return when searching category 5 would be
/?post_category=5&s=
instead of
/s=

i am in search of multiple category or tags search plugin. I have tried a plugin that is multi category search widget but it is not helping me as i need. i have a <a href=”http://www.best-tv-price-review-india.com” target=”_blank”>television</a><br />site and i am looking for a plugin that can help my users to select television by category

great snippet man!
i was trying to make two checkboxes to give the possibility to the user to decide in wich category to search.
i have only two category in my website, but it doesn t work..seems that that the form add to the url the category filter only when it is passed by an “input=”hidden”..is it possible?
this is the code i tried..:
<code>
<form method=”get” id=”searchform” action=”<?php bloginfo(‘url’); ?>/”>
<input type=”text” value=”<?php echo wp_specialchars($s, 1); ?>” name=”s” id=”s” />
<input type=”checkbox” name=”cat” value=”3″ />News
<input type=”checbox” name”cat” value”4″/>Annunci
<input type=”submit” id=”searchsubmit” class=”submit” value=”Cerca” />
</form>
thanks in advance!
<code>

Sorry, but you are required to use a javascript enabled brower to comment here.

About WPGarage

This is where Rebecca and Miriam from illuminea (and sometimes others) document things they've learned about WordPress. Even after nine years in the field, we're always learning new things about WordPress. Hope this helps you too.