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="/" 
input type="text" value="" name="s" id="s"
input type="hidden" value="22" name="cat" id="scat"
/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://www.wordpress-designer.co.uk/?s=WordPress to http://www.wordpress-designer.co.uk/?s=WordPress&cat=22 and will only return posts in the category ID you choose.

About The Author

Jim Callender is a Freelance Wordpress Developer. Living & working in Brighton. He started working with Wordpress in 2003. Since then has been responsible for delivering high profile sites for a number of large UK design & marketing agencies. His other site is www.jayonline.co.uk