I have a search form consists of several "select" which list various terms of a taxonomy ('State'). By pressing the submit button, I pass the information to a search results page on which I build the query.
The problem is that I need to build the query dynamically because it is not obligatory to choose values for each of the "select". So some values are sent empty.
$country = $_POST["country"]; $city = $_POST["city"];
If $city is empty, the query should be like:
$my_query = new WP_Query(array( 'state' => $country ) );
But if $country and $city are not empty, de query should be like:
$my_query = new WP_Query(array( 'state' => $country, 'state' => $city ) );
How can I do it?