WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] List authors with avatar pic and last posts? (6 posts)

  1. hungzai
    Member
    Posted 4 years ago #

    Is it possible to list the authors of a website, with avatar pic and also last posts of the author?

    What I'm doing now is manually list all the authors which is slightly inconvenient since when there are new authors, I have to add on to the list manually.

    Just wondering could it be done with just a piece of code?

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    Yeah....you could make a page template and have the list of authors automaticcally generated. This could possibly get you started in the right direction
    http://codex.wordpress.org/Template_Tags/wp_list_authors

  3. MichaelH
    Member
    Posted 4 years ago #

    <?php
    //displays all users with their avatar and their posts (titles)
    $blogusers = get_users_of_blog();
    if ($blogusers) {
      foreach ($blogusers as $bloguser) {
        $user = get_userdata($bloguser->user_id);
        echo '<p>User ID ' . $user->ID . ' ' . $user->user_firstname . ' ' . $user->user_lastname . '</p>';
        echo get_avatar( $user->ID, 46 );
        $args=array(
          'author' => $user->ID,
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => -1,
          'caller_get_posts'=> 1
        );
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          //echo 'List of Posts for ' . user->user_firstname . ' ' . $user->user_lastname;
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
            <?php
          endwhile;
        }
      wp_reset_query();  // Restore global post data stomped by the_post().
      }
    }
    ?>
  4. hungzai
    Member
    Posted 4 years ago #

    Thanks guys. It worked like a charm!!!!!

  5. Gabriel
    Member
    Posted 4 years ago #

    Thanks! This saved my day!

  6. Hassan Akhtar
    Member
    Posted 3 years ago #

    Hi,
    I want to show just the authors of my blog. This code is displaying the contributors as well. Is that possible?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags