WordPress limit search form to a category



function submitter()



<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″ />




source: http://wpgarage.com/code-snippets/how-to-hack-the-wordpress-search-function-search-categories-and-child-categories/


One Response to “WordPress limit search form to a category”

  1. Wordpress affect categories search form searches – solution 2 | alexyz Says:

    […] see this post if you’re only wanting to limit the form to a single category, as it’s as simple as […]

Leave a Reply

You must be logged in to post a comment.