WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to make dropdown list of archives by date and/or categories? (14 posts)

  1. Ciryaquen
    Member
    Posted 7 years ago #

    Searching for dropdown list for archives lead to the Template_Tags/dropdown_cats and Template_Tags/get_archives articles. The codex flags the functions as deprecated.

    Is there another way to make a drop down list of the archives? I'm not a pro, so please keep answers dumbed down. :) Thanks!

  2. martinhipp
    Member
    Posted 7 years ago #

    <select name="archive-menu" onChange="document.location.href=this.options[this.selectedIndex].value;">
    <option value="">Select month</option>
    <?php wp_get_archives('type=monthly&format=option'); ?>
    </select>

  3. Ciryaquen
    Member
    Posted 7 years ago #

    Thank you, Martin!! That works perfectly.

  4. tomcho
    Member
    Posted 6 years ago #

    Thanks - this was just what I needed too.

  5. harknell
    Member
    Posted 6 years ago #

    If you don't want to actually alter your theme files you could add my AWSOM Drop Down Archive plugin which will display a post drop down archive for you after activation.

  6. johanansen
    Member
    Posted 6 years ago #

    How do I set the drop down menu to show annual archive pages instead of monthly ones?

    Also, can the same be done for archives?

    BR,
    - Johanan

  7. RuthHendrickson
    Member
    Posted 6 years ago #

    the code that martinhipp posted -- exactly which file is it to be copied into?

  8. blork
    Member
    Posted 6 years ago #

    Huh? Martinhipp, where does that code go? (Please be specific, I'm not a programmer.)

  9. laslo
    Member
    Posted 6 years ago #

    Is there something similar to

    wp_get_archives('type=monthly&format=option)

    but for Categories?
    I need the "format=option" part, cos wp_dropdown_categories is useless. it will only list the categories, if I select one it won't go to a new page.

  10. arcab4
    Member
    Posted 6 years ago #

    didn't want to start a new thread on this...

    but what would you do for posts?

    <select name="archive-menu" onChange="document.location.href=this.options[this.selectedIndex].value;">
    <option value="">Select month</option>
    <?php query_posts('format=option');?>
    </select>

    that unfortunately doesn't work...tried to replace out the

    wp_get_archives('type=monthly&format=option)

    i've also looked at this plugin here

    http://www.dagondesign.com/articles/drop-down-post-list-plugin-for-wordpress/

    but doesn't seem to work. says it's good to 2.3 but we're already at 2.3.1

    any suggestions?

  11. blork
    Member
    Posted 6 years ago #

    Follow-up question: I used Martinhipp's code and it works just fine (WP 2.3.1), but I would like to make the text box a bit wider. Currently, when you drop down the list, the last few characters of some items are truncated.

    Is there some way to make the box wider?

  12. Len Kutchma
    Member
    Posted 6 years ago #

    Is there some way to make the box wider?

    I wasn't even going to read this thread as it was marked Resolved. Yes you can make it as wide/narrow as you want with a couple of simple mods.

    First, add a class attribute to the above code. Something like class="dropdown" so that code should now look like...

    <select name="archive-menu" class="dropdown" onChange="document.location.href=this.options[this.selectedIndex].value;">
    <option value="">Select month</option>
    <?php query_posts('format=option');?>
    </select>

    Next add the styling info for that class to your style sheet. Something like...

    .dropdown {
    font-family: arial;
    font-size: 9px;
    color: #000000;
    width:150px;
    background-color: #FFFFFF;
    }

    Adjust the values the way you like.

  13. blork
    Member
    Posted 6 years ago #

    Thanks!

  14. rotarypot
    Member
    Posted 6 years ago #

    Could this be done also for making a dropdown of bookmarks categories and displaying according to the user's choice??

Topic Closed

This topic has been closed to new replies.

About this Topic