Forums

List of authors with avatars (1 post)

  1. khaxan
    Member
    Posted 1 year ago #

    Hi,

    I am trying to display a list of 10 random Authors (no other role) on my site but I can't do so. Here's the code that I am using:

    function contributors() {
    global $wpdb;
    
    $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");
    
    foreach($authors as $author) {
    echo "<li>";
    echo "<a href=\"".get_bloginfo('url')."/?author=";
    echo $author->ID;
    echo "\">";
    echo get_avatar($author->ID);
    echo "</a>";
    echo '<div>';
    echo "<a href=\"".get_bloginfo('url')."/?author=";
    echo $author->ID;
    echo "\">";
    the_author_meta('display_name', $author->ID);
    echo "</a>";
    echo "</div>";
    echo "</li>";
    }
    }

    This code displays all the users but I want to limit them to 10 and also I want to show just the authors.

    Thanks in advance

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags