WordPress limit search form to a category
Thursday, December 9th, 2010example:
<script>
function submitter()
{
track_it(‘/podcast/searchFormSubmit/’);
document.searchform.submit();
}
</script>
<form method=”get” name=”searchform” id=”searchform” action=”<?php bloginfo(‘url’); ?>/”>
<input type=”text” value=”<?php the_search_query(); ?>” name=”s” id=”s” onclick=”this.value=””/>
This is the important new line, 5 is an example category id
<input type=”hidden” name=”cat” value=”5″ />
<a href=”javascript:submitter()” style=”text-decoration:none;font-size:11px;margin:0 0 0 5px;position:absolute;top:0px;”><img src=”wp-content/themes/New/images/go.png” onmouseover=”this.src=’wp-content/themes/New/images/go-over.png’” onmouseout=”this.src=’wp-content/themes/New/images/go.png’” border=”0″ />
</a>
</form>