Created
May 31, 2013 12:26
-
-
Save javierarques/5684664 to your computer and use it in GitHub Desktop.
Dropdown for taxonomies
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
function dropdown_taxonomy ( $taxonomy, $all_option = 'todo') { | |
$terms = get_terms ( $taxonomy ); | |
?> | |
<!-- START taxonomy Search --> | |
<select name="<?php echo $taxonomy ?>"> | |
<option value=''><?php echo $all_option ?></option> | |
<?php foreach($terms as $term): ?> | |
<option value="<?php echo $term->name ;?>" <?php selected(get_query_var($taxonomy), $term->name, true) ?>> | |
<?php echo $term->name ?> | |
</option> | |
<?php endforeach; ?> | |
</select> | |
<!-- END taxonomy Search --> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment