Arbitrary taxonomy — drop-down list of countries, cities and dates in WordPress?

Good afternoon, dear friends!

Can you please tell me a tip how to implement a drop-down list of countries, cities and dates.
Actually, I realized a country, city, date, but the question is:

1. The drop-down list of countries choose, for example, Russia, in the next window, falls city, e.g. Moscow, in the last window of a month, for example, only the active (for example, excursions are only in January, March, August, and other months not shown).

2. How to implement if the search form if you click Find without filtering out all records from Countries, Cities, Months.

3. Plugins don't use, made by adding arbitrary records as Countries, Cities, Months, only filters. The list of countries is small, only 10 cities about 30, months 12, years are added.

Thank you very much!
July 2nd 19 at 17:05
2 answers
July 2nd 19 at 17:07
Country and city do a nested taxonomy, date metadata.
Then the question will be to form the url with all the selected parameters, and then using pre_get_posts hook pick these options by using get_query_var() and modifying the main query (tax_query to enter a country/city and meta_query for dates).
July 2nd 19 at 17:09
Thank you, Igor, for your reply, I have this:

<script type="text/javascript">
// Countries
var country_arr = new Array("Russia", "Ukraine", "Kazakhstan");

// States
var s_a = new Array();
s_a[0] = "";
s_a[1] = "Moscow|St.-Petersburg";
s_a[2] = "Kiev|Odessa";
s_a[3] = "Astana";
s_a[4] = "Direction";


function populateStates(countryElementId, stateElementId) {

 var selectedCountryIndex = document.getElementById(countryElementId).selectedIndex;

 var stateElement = document.getElementById(stateElementId);

 stateElement.length = 0; // Fixed by Julian Woods
 stateElement.options[0] = new Option('Direction', ");
 stateElement.selectedIndex = 0;

 var state_arr = s_a[selectedCountryIndex].split("|");

 for (var i = 0; i < state_arr.length; i++) {
 stateElement.options[stateElement.length] = new Option(state_arr[i], state_arr[i]);
}
}

function populateCountries(countryElementId, stateElementId) {

 var countryElement = document.getElementById(countryElementId);
 countryElement.length = 0;
 countryElement.options[0] = new Option('Country', '-1');
 countryElement.selectedIndex = 0;
 for (var i = 0; i < country_arr.length; i++) {
 countryElement.options[countryElement.length] = new Option(country_arr[i], country_arr[i]);
}

 if (stateElementId) {
 countryElement.onchange = function () {
 populateStates(countryElementId, stateElementId);
};
}
}

</script>


And the form itself:

<form action="<?php echo home_url ?>" method="get">
 <label for="locations"></label>
 <select id="country" name="country"></select>
 <label for="city"></label>
 <select name="city" id="state"></select>

 <label for="dates"></label>
 <select name="dates" id="dates">
 <option value="all" selected="selected">Select date</option>
 <option value="January">January</option>
 <option value="February">February</option>
 <option value="March">March</option>
 <option value="April">April</option>
 <option value="May">May</option>
 <option value="June">June</option>
 <option value="July">July</option>
 <option value="August">August</option>
 <option value="September">September</option>
 <option value="October">October</option>
 <option value="November">November</option>
 <option value="December">December</option>
</select>
 <input type="submit" name="submit" id="submit" value="Find"></form>


And, adding a post, for example, Medical exhibition, Russia, Moscow, Oct - me for it, but how to make the month of October only active in this case, does not work.

Find more questions by tags TaxonomyWordPress