Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have narrowed the code down to this:

<?php
    $authors = $wpdb->get_results('SELECT DISTINCT post_author FROM '.$wpdb->posts);
    if($authors):
    foreach($authors as $author):

    ?>

I would like the authors to be sorted Alphabetically, it doesn't matter if it sorts by first name, last name.

share|improve this question
    
What do you want as an end result? A list of names, a list of author ids? –  Douglas.Sesar Sep 12 '12 at 4:40
    
A list of names –  Rocco Freer Sep 16 '12 at 7:41
add comment

1 Answer

Your Query gets the authors ID and is you want them sorted Alphabetically you will need to get the author(user object) so try:

$authors = $wpdb->get_results('SELECT DISTINCT post_author FROM '.$wpdb->posts);
if($authors){
    $users = get_users( array(
        'include' => $authors,
        'orderby' =>  'display_name'
    ));
    foreach ((array)$users as $user) {
       echo '<li>' . $user->display_name. '</li>';
    }
}
share|improve this answer
    
There is no tag in the answer so your problem is not comming from here –  Bainternet Sep 17 '12 at 8:27
1  
Thanks, For your help –  Rocco Freer Sep 28 '12 at 2:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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