WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Alphabetizing dropdown categories in 2.3 (6 posts)

  1. msadventures
    Member
    Posted 6 years ago #

    Hi all - I've just put a code in the sidebar of my theme for dropdown categories, and it worked fine on earlier versions of WP, but now the alphabetizing doesn't work in 2.3, can anyone help?

    Here's the code I'm using:

    <ul>
    <li>
    <form action="<?php echo $PHP_SELF ?>" method="get">
    <div style="text-align:center">
    <p><?php dropdown_cats(TRUE, 'Choose...', 'NAME'); ?></p>
    <p><input type="submit" name="submit" value="Go!" /></p>
    </div>
    </form>
    </li>
    </ul>

    TIA!
    Michelle

  2. msadventures
    Member
    Posted 6 years ago #

    I've been searching around, trying to figure out how to fix this. So far I've tried switching to just this:

    <?php wp_dropdown_categories(); ?>

    but again, can't figure out how to get it to alphabetize. I've tried putting in sort_column=name, and that's not working.

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Try this:
    wp_dropdown_categories('orderby=name');

    The documentation: http://codex.wordpress.org/Template_Tags/wp_dropdown_categories

  4. msadventures
    Member
    Posted 6 years ago #

    Ah, thanks that one worked! I'd also like to set it so that a category doesn't show up in the window, but instead the word "Choose..." or something like that, but I can't quite figure out, from that link you gave me, how to fix it to say that. I know I need to fix one of those variables, but I'm not sure what I need to enter or leave out as far as that code in the "default" box, if that makes any sense.

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    You'd either use show_option_all or show_option_none, depending on what you want the "Choose..." itself to do.

    Like so:
    wp_dropdown_categories('orderby=name&show_option_all=Choose...');

    Or so:
    wp_dropdown_categories('orderby=name&show_option_none=Choose...');

    Or even both:
    wp_dropdown_categories('orderby=name&show_option_all=Choose...&show_option_none=---');

    That last one uses the "none" as a separator.

  6. msadventures
    Member
    Posted 6 years ago #

    Aha! That first one was just what I was after, thanks Otto! :D

Topic Closed

This topic has been closed to new replies.

About this Topic