2

Sorry if this is a silly question but is it possible to have a taglist as a dropdown?

I have a page where users can post theyre own content, and I would like them to be able to choose certain tags as a dropdown, is this possible?

Heres the page so you can see http://wordpress.art-williams.com/add-destination

I appreciate any help what so ever, anything is a huge help!

Thanks

1 Answer 1

4

You can use wp_dropdown_categories() to create your dropdown:

wp_dropdown_categories(array('taxonomy'=> 'post_tag','hide_empty' => 0, 'name' => 'my_tags'));

Update

the reason you are getting the term ID is because wp_dropdown_categories sets the ID's as values so instead of just echo'ing it out you need to get the term, something like:

$term = get_term_by('id',$your_id,'post_tag');
echo $term->name;
14
  • Oh wow you are a genius! :) Thank you, if I wanted to exclude a tag from that list, would I just need to put in 'exclude=ID' ?
    – Art
    Commented Aug 16, 2011 at 14:19
  • @art: yep just add exclude with id to the array.
    – Bainternet
    Commented Aug 16, 2011 at 14:25
  • Ok sorry i have tried this wp_dropdown_categories(array('taxonomy'=> 'post_tag','exclude=6', 'hide_empty' => 0, 'name' => 'my_tags')); and it isnt working
    – Art
    Commented Aug 16, 2011 at 14:29
  • because its wrong syntax, change'exclude=6' to 'exclude'=>6
    – Bainternet
    Commented Aug 16, 2011 at 14:51
  • Glad I could help.
    – Bainternet
    Commented Aug 16, 2011 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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