1

I have a custom taxonomy filled with terms that I wish to display in a fashion such as below.

<option value="[SLUG]">[TERM]</option>
<option value="[SLUG]">[TERM]</option>
<option value="[SLUG]">[TERM]</option>
...

I have attempted to use "wp_dropdown_categories" but I was unable to find a way to change the value="[TERM_ID]" to value="[SLUG]"

I also tried to use "wp_list_categories" and have it display with out the li's hoping there was a tag like "wp_nav_menu" has with 'before'=>'','after'=>'' but the documentation for "wp_list_categories" doesn't seem to support that.

If you have any ideas on how to accomplish this it would be much appreciated.

1

Use get_terms and output the term objects within whatever markup you need:

$terms = get_terms( 'your-taxonomy' );

if ( $terms ){

    echo '<select>';

    foreach ( $terms as $term ) {
        echo '<option value="' . $term->slug . '">' . $term->name . '</option>';
    }

    echo '</select>';

}
1
  • this is perfect.
    – Phil Hoyt
    Jul 26 '13 at 3:41

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.