• Resolved hungzai

    (@hungzai)


    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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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
    https://codex.www.ads-software.com/Template_Tags/wp_list_authors

    <?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().
      }
    }
    ?>
    Thread Starter hungzai

    (@hungzai)

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

    myCred

    (@designbymerovingi)

    Thanks! This saved my day!

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘List authors with avatar pic and last posts?’ is closed to new replies.