• Resolved Phil

    (@owendevelopment)


    Hi,

    I’m using a custom SQL query to fetch a list of authors.

    While I have it working and excluding certain ID’s (admins etc), the list is coming in ordered by ID.

    Can someone please help me reorder this list by the users’ name? It’s nearly 3am, I’m a SQL noob and I’ve tried doing this myself with no joy.

    My code so far:

    <?php
       $excluded = "1,77"; // To exclude admin ID's
       $sql = 'SELECT DISTINCT post_author FROM '.$wpdb->posts. " WHERE post_author NOT IN ($excluded) ORDER BY ID ASC";
       $authors = $wpdb->get_results($sql);
       if($authors):
       foreach($authors as $author):
    ?>

    [No bumping. If it’s that urgent, consider hiring someone.]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need Author List Ordering by Name’ is closed to new replies.