Search Specific Category in WordPress
There are some times when you want to limit your search to a particular category, or perhaps multiple categories. This is relatively simple to do in WordPress by adding a hidden field to your search code. (See example below)
<form method="get" id="search form" action="/"> <div> <input type="text" value="" name="s" id="s" /> <input type="hidden" value="22" name="cat" id="scat" /> <input type="submit" id="search_submit" name="Search" value="Search"/> </div> </form>
You can see I added my hidden input field on the third line. When I add this in, it then adds onto the query used to search. Your search will go from something like http://jzelazny.wpengine.com/?s=WordPress to http://jzelazny.wpengine.com/?s=WordPress&cat=22 and will only return posts in the category ID you choose.