Created
March 18, 2014 11:35
-
-
Save ellefsen/9618353 to your computer and use it in GitHub Desktop.
searchform.php with tax-term filter
This file contains 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 role="search" method="get" id="searchform" action="<?php bloginfo('home'); ?>"> | |
<input type="text" value="" name="s" id="s" /> | |
<?php | |
function get_terms_dropdown($taxonomies, $args){ | |
$myterms = get_terms($taxonomies, $args); | |
$selected = "selected"; | |
$output ="<select><option selected='".$selected."'>Select a Category</option>'"; | |
foreach($myterms as $term){ | |
$term_taxonomy=$term->My_Taxnomy; | |
$term_slug=$term->slug; | |
$term_name =$term->name; | |
$output .="<option name='".$term_slug."'>".$term_name."</option>"; | |
} | |
$output .="</select>"; | |
return $output; | |
} | |
$taxonomies = array('My_Taxonomy'); | |
$args = array('order'=>'ASC','hide_empty'=>true); | |
echo get_terms_dropdown($taxonomies, $args); | |
?> | |
<input type="submit" id="searchsubmit" value="Search" /> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment