Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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>';

}
share|improve this answer
    
this is perfect. –  Phil Hoyt Jul 26 '13 at 3:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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