I'm trying to let users have a filter option when they submit a search.
My search form:
<form class="searchform" method="get" action="http://www.example.com/">
<input class="search" name="s" type="text" value="Search Here"/>
<select name="search_type" id="cat" class="postform" style="display: none; ">
<option value="all" selected="selected">both</option>
<option class="level-0" value="filterone">filterone</option>
<option class="level-0" value="filtertwo">filtertwo</option>
</select>
<button value="submit" class="searchBtn"><span class="hidden">Submit</span></button>
</form>
The problem im having is that the optoin paremeters im passing through the url are removed. for example when I go to:
http://www.example.com/?s=apple&search_type=filterone
I am imediatley returned to:
http://www.example.com/?s=apple
Ive tried many different things to make this work, but it still doesn't work:
add_filter('query_vars', 'search_vars' );
function search_vars( $qvars )
{
$qvars[] = 'search_type';
return $qvars;
}
function my_search_filter( $query )
{
if( is_search() )
{
$query->set( 'search_type', 'schools' );
}
}
add_filter( 'pre_get_posts', 'my_search_filter' );
When I go to any other page besides the home page, the url parameters work fine. Also I am using custom permalinks. I hope this is enough information.
So my question is, how can I stop the parameter variables from being removed?
add_query_arg... – soulseekah Mar 24 '12 at 15:52add_query_varactually :) thanks for pointing that out. – soulseekah Mar 25 '12 at 3:16