X

Display List of Authors in a Dropdown Menu Using wp_dropdown_users

Snippets by IsItWP

Are you looking for a way to display blog authors in a dropdown menu? Listing authors will help users find author specific posts. We have created a quick code snippet that you can use to display list of authors in a dropdown menu using wp_dropdown_users in WordPress.

Instructions:

All you have to do is add this code to a theme’s file or in a site-specific plugin:

<li id="users">
 <h2><?php _e('users:'); ?></h2>
   <form action="<?php bloginfo('url'); ?>" method="get">
   <?php 
     $args = array(
   	 'exclude'                 => '1',
   	 'name'                    => 'authors',
   	 'who'                     => 'authors'
    );
    wp_dropdown_users($args); 
   ?>
   <input type="submit" name="submit" value="view" />
   </form>
</li>

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: How to create a WordPress donation form and How to add a portfolio to your WordPress site.

Comments   Leave a Reply

  1. it should actually be 'name' => 'author', (without the “s”) otherwise you will not end up on the authors profile page

  2. I have a Query. I need a dropdown list which should display users except the admin and the current user id who is logged in. How to accomplish this scenario?

  3. Hi there– this is great, two questions: 1. Where do I add this in my theme template? 2. How do I have it include only users with the role of “contributor”? Thanks!

  4. Kevin — maybe you can help. I’ve been searching for a couple days. I am after code to make a drop down list of POSTS. The Codex covers everything but that, which seems a strange oversight.

    I’ve found two sources, mainly the Dagon code which works but is too complex for my weak PHP skills to style (width and background color for example).

    I know that some javascript is needed to make the code dynamic, but it can’t be that complex. So, what is the magic bullet to turn a list of … anything into a drop down format? The Codex addresses pages, archives, tags, and about anything for drop downs except posts.

    Any guidance is appreciated
    Mike

    1. Hi Mike,
      Well this should solve your problem, http://pastebin.com/uAiujNYL
      If I could specify post_type within wp_dropdown_pages that would solve things but does not appear to work. However the code I put online at pastebin should work fine for you and nice and sample. Place that code in any location within your wordpress theme.

      1. Kevin, thank you!!! Works like a charm. NOW :), and I don’t mean to try your patience and time, but can you also tell how to add a line of javascript to make each drop down link clickable. I do have code from a site that has a permalink with a click but the problem is that there’s no –Select an item– as the first entry, the null value, so that this first item can never be used.  Need like (in the your drop down box):
        — Select an item —
        clickable item A
        clickable item B
        etc.

        Javascript is something I don’t enjoy LOL It is in no way intuitive. Anyway, this last piece will complete the puzzle. Again, I’ve played with the Dagon script but it’s too complex to alter.

        Mike

        1. Hi Mike ill post this as a snippet this week.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!