All tags in a drop-down menu (aka select box)

Published: On Thursday, March 13, 2008

You may will like to display all your tags in a drop-down (it's already possible with categories and thanks to a plugin, with posts too).
preview example: tags in a dropdown

And remember, since this is some kind of raw code (I share it rather as a possible inspiration than as a finished optimized solution), it's except else not accessible with disabled java-script.

<?php

$args = array(
        'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 999,
        'format' => 'array', 'orderby' => 'name', 'order' => 'ASC',
        'exclude' => '', 'include' => '');

$tags = get_tags($args);

?>


<form action="<?php bloginfo('url'); ?>" method="get">
        <select id="select-of-tags" name="tag" onchange="if(this.selectedIndex){location.href=(this.options[selectedIndex].value)}">
                <option value="">Select an option...</option>

<?php foreach ($tags as $tag) {?>
                <option value="<?php bloginfo('url'); ?>/tag/<?php echo $tag->slug ?>"><?php echo $tag->name ?></option>
<?php } ?>
        </select>
</form>

Comments

  1. 1.  chris wrote: On March 27., 2009 comment number 1

    though it's been more than a year, it still works, even on wp 2.7

    Thank you so much, it works perfectly on my new blog, and you're the only one who knows how to have tags displayed in dropdown menu, you're a genius!

  2. 2.  Kahi [author] wrote: On March 27., 2009 comment number 2

    ↪ chris I'm glad it helped somebody!

  3. 3.  ron wrote: On May 18., 2009 comment number 3

    do you know of a similar script for authors? I would like to list authors in a drop down script.

  4. 4.  Kahi [author] wrote: On May 18., 2009 comment number 4

    ↪ ron I don't know. Try to see codex/relevant functions (wp_list_authors etc.), plugins, support forum or just google…

  5. 5.  ron wrote: On May 19., 2009 comment number 5

    I tried all of the above but have not found anything. I will keep on trying :-)

    thanks

  6. 6.  Alex wrote: On September 28., 2011 comment number 6

    Greatings from Greece,
    It is possible to creat 2 SELECT BOX's with tags(include=1'2'3) and Submit Button ?
    Like this
    1ST SELECT BOX(include=1,2,3) + 2ND SELECT BOX(include=4,5) + SUBMIT = Tags.php

I quit working with WordPress, comments are closed. My plugins will not be updated any more – at least not by me. Feel free to modify my source codes though… Also I am not able to provide support, sorry. –Kahi