Skip to content

Instantly share code, notes, and snippets.

@javierarques
Created May 31, 2013 12:26
Show Gist options
  • Save javierarques/5684664 to your computer and use it in GitHub Desktop.
Save javierarques/5684664 to your computer and use it in GitHub Desktop.
Dropdown for taxonomies
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