Created
July 12, 2020 14:30
-
-
Save Fixmysite/313b20dad19d1bda44464cca14ab65d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <form method="GET" class="wine-search"> | |
| <label for="varieties">All varieties:</label> | |
| <select name="varieties[]" id="varieties"> | |
| <option value="" disabled selected>Select a variety</option> | |
| <?php | |
| $svarieties = get_terms([ | |
| 'taxonomy' => 'varieties', | |
| 'hide_empty' => false, | |
| ]); | |
| foreach ($svarieties as $sv) { ?> | |
| <option value="<?php echo $sv->name ?>" <?php selected( (isset($_GET['varieties']) && in_array($sv->name, $_GET['varieties'])) ) ?>><?php echo $sv->name ?></option> | |
| <?php } ?> | |
| </select> | |
| <label for="years">All years:</label> | |
| <select name="years[]" id="years"> | |
| <option value="" disabled selected>Select a year</option> | |
| <?php | |
| $syears = get_terms([ | |
| 'taxonomy' => 'years', | |
| 'hide_empty' => false, | |
| ]); | |
| foreach ($syears as $sy) { ?> | |
| <option value="<?php echo $sy->name ?>" <?php selected( (isset($_GET['years']) && in_array($sy->name, $_GET['years'])) ) ?>><?php echo $sy->name ?></option> | |
| <?php } ?> | |
| </select> | |
| <label for="awards">All awards:</label> | |
| <select name="awards[]" id="awards"> | |
| <option value="" disabled selected>Select a year</option> | |
| <?php | |
| $sawards = get_terms([ | |
| 'taxonomy' => 'awards', | |
| 'hide_empty' => false, | |
| ]); | |
| foreach ($sawards as $sa) { ?> | |
| <option value="<?php echo $sa->name ?>" <?php selected( (isset($_GET['awards']) && in_array($sa->name, $_GET['awards'])) ) ?>><?php echo $sa->name ?></option> | |
| <?php } ?> | |
| </select> | |
| <button type="submit">Show wines</button> | |
| <a href="#" class="clear-wine-seach">Clear</a> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> | |
| <script type="text/javascript"> | |
| jQuery(document).ready(function($){ | |
| $('.clear-wine-seach').click(function(e) { | |
| e.preventDefault(); | |
| $('.wine-search').find('select').prop('selectedIndex',0); | |
| }) | |
| }); | |
| </script> | |
| </form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment