Here is a quick example that will help you create a drop down menu, populated with all of the terms from a custom taxonomy.
This code is mostly from this thread on WordPress.com forums, I’ve just changed a few things for my situation.
Here’s the function that does most of the hard work.
function get_terms_dropdown($taxonomies, $args){
$myterms = get_terms($taxonomies, $args);
$output ="<select name='buscategory'>";
$output .="<option value='#'>Please select a business category</option>";
foreach($myterms as $term){
$root_url = get_bloginfo('url');
$term_taxonomy=$term->taxonomy;
$term_slug=$term->slug;
$term_name =$term->name;
$link = $term_slug;
$output .="<option value='".$link."'>".$term_name."</option>";
}
$output .="</select>";
return $output;
}
Then place this code where you would like to call the drop down menu, this could be using a hook or in your template files.
<form action="<?php bloginfo('url'); ?>" method="get">
<p>Or search for a service from the drop down menu:</p>
<?php
$taxonomies = array('buscategory');
$args = array('orderby'=>'name','hide_empty'=>true);
$select = get_terms_dropdown($taxonomies, $args);
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
?>
<noscript><div><input type="submit" value="Go" /></div></noscript>
</form>
</div>
You’ll need to update the name of the taxonomy for this to work, you’ll see in the above example I’ve used ‘buscategory’ it needs to be update in both code blocks.

I tried your code, but I don’t know why doesn’t work for me. I changed the name of taxonomy to my taxonomy, which is ‘subjects’, but I just get a dropdown with nothing in it. Any ideas?
Hi Petra, did you put the function “get_terms_dropdown($taxonomies, $args)” into your site as well? Probably in the functions.php file ??
Also ensure that you have PHP errors turned on so that you see any problem when you execute the form.
Let me know how you go
Peter
Thanks for your quick reply Peter!
In my functions.php I have this:
function get_terms_dropdown($taxonomies, $args){
$myterms = get_terms($taxonomies, $args);
$output =”";
$output .=”Please select a subject”;
foreach($myterms as $term){
$root_url = get_bloginfo(‘url’);
$term_taxonomy=$term->taxonomy;
$term_slug=$term->slug;
$term_name =$term->name;
$link = $term_slug;
$output .=”".$term_name.”";
}
$output .=”";
return $output;
}
And in my archives-video.php I have this:
<form action="” method=”get”>
‘name’,'hide_empty’=>true);
$select = get_terms_dropdown($taxonomies, $args);
$select = preg_replace(“#]*)>#”, “”, $select);
echo $select;
?>
I put the name of my taxonomy here -> $taxonomies = array(‘subjects’);
Where I am registering my taxonomy I have this code:
//subject
$subjectlabels = array(
‘name’ => _x( ‘Subjects’, ‘taxonomy general name’ ),
‘singular_name’ => _x( ‘Subject’, ‘taxonomy singular name’ ),
‘search_items’ => __( ‘Search Subjects’ ),
‘all_items’ => __( ‘All Subjects’ ),
‘parent_item’ => __( ‘Parent Subject’ ),
‘parent_item_colon’ => __( ‘Parent Subject:’ ),
‘edit_item’ => __( ‘Edit Subject’ ),
‘update_item’ => __( ‘Update Subject’ ),
‘add_new_item’ => __( ‘Add New Subject’ ),
‘new_item_name’ => __( ‘New Subject Name’ ),
‘menu_name’ => __( ‘Subjects’ ),
);
register_taxonomy(‘subjects’, ‘videos’, array (
‘hierarchical’ => true,
‘labels’ => $subjectlabels,
‘show-ui’ => true,
‘query_var’ => true,
‘rewrite’ => array (‘slug’ => ‘subject’)
));
I wonder what I am missing?
Sorry the code for the dropdown is this (didn’t paste it correctly):
<form action="” method=”get”>
‘name’,'hide_empty’=>true);
$select = get_terms_dropdown($taxonomies, $args);
$select = preg_replace(“#]*)>#”, “”, $select);
echo $select;
?>
For some reason it strips out part of my code. Here it is on another website:
http://codepad.org/A5saoAgb
Good news! i managed to solve the problem. taxonomy name wasn’t really correct and the way it was registered.
http://codex.wordpress.org/Function_Reference/register_taxonomy
Hi Petra,
Just saw your comments, and happily the last one says you got it working – well done!
Peter