Created
January 15, 2021 20:39
-
-
Save jbd91/92be05e789f7cf73cd6959ca83d99416 to your computer and use it in GitHub Desktop.
Hierarchial Mixitup Select Filter
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
<div class="filter-controls"> | |
<div class="filter-controls__drop-down"> | |
<select id="filterSelect"> | |
<?php $hiterms = get_terms("dealer_locations", array("orderby" => "slug", "parent" => 0)); ?> | |
<?php foreach ($hiterms as $key => $hiterm) : ?> | |
<optgroup label="<?php echo $hiterm->name; ?>"> | |
<?php $loterms = get_terms("dealer_locations", array("orderby" => "slug", "parent" => $hiterm->term_id)); ?> | |
<?php if ($loterms) : ?> | |
<?php foreach ($loterms as $key => $loterm) : ?> | |
<option data-filter=".<?php echo $loterm->slug; ?>"><?php echo $loterm->name; ?></option> | |
<?php endforeach; ?> | |
<?php endif; ?> | |
</optgroup> | |
<?php endforeach; ?> | |
</select> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment