My theme's search.php
currently has a few "IF" statements to deal with the different types of search that my website uses.
I have a site-wide search, a species (custom post type) specific search and an advanced species search.
For the "species" search, I've simply added an input akin to <input type="hidden" name="type" value="species" />
. This search uses a single input field to search my species custom post type. Users would likely opt to use this search if they were looking for the common or scientific name of a fish.
For the "advanced species" search, I'm using 12 different inputs (pH, size, temp, etc). I'm building an $args array for meta_query
in the WP_Query
class with this data, i.e:
array(
'key' => 'genus',
'value' => $_GET["genus"]
)
As a result however, the generic <input name="s">
isn't being used, and as such, the form action isn't working (just loads the index page without searching).
Is there a better way of doing this? I could obviously just send "s" as a hidden input with a generic value, but that's a cheap and ugly way of going about things.
Maybe this should be a page separate to our search page? I'd prefer to do it in search.php
though or there will be some redundant copying of HTML structure etc for no real reason.
Thanks in advance,