Similiar to category drop down box for a list of terms with the same parent, I want to make such a drop down for a list of tags with the same group name( or some other conditions that works). Seems WP doesn't provide a way to use term group, any other way to make the drop down ?

  • 1
    If your terms are grouped they are hierarchical. So use a hierarchical taxonomy instead. – fuxia Jan 6 '12 at 2:01
  • 1
    The term_group is used internally for term aliasing, you shouldn't really try to override it with anything. – Otto Sep 11 '12 at 20:07

The examples i quote in my answer can be found here, i also recommend you read that page carefully to help you with this.

But lets grab an existing example there and change it a bit.


//you must change the parameters in the get_terms function to get exactly the terms you want
$terms = get_terms("my_taxonomy");
$count = count($terms);
if ( $count > 0 ){

    //the onchange value allows you to go to the term page when you select it, if you dont want that, remove it and remove the value in the options too
    echo '<select onchange="document.location.href=this.options[this.selectedIndex].value;">';
    foreach ( $terms as $term ) {
      echo '<option value="'.get_term_link($term->slug, 'CHANGE-THIS-TO-YOUR-TAXONOMY-NAME').'">' . $term->name . '</option>';
    echo "</select>";

//more on the get_term_link function here: http://codex.wordpress.org/Function_Reference/get_term_link


I hope this answers your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.