Forums

[resolved] Need Author List Ordering by Name (3 posts)

  1. Phil
    Member
    Posted 4 months ago #

    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.]

  2. Phil
    Member
    Posted 4 months ago #

    Never mind - I fixed it.

  3. RandallFlagg
    Member
    Posted 4 months ago #

    Can you share?

Reply

You must log in to post.

About this Topic