• Resolved callender

    (@jimcallender)


    Hi,

    I want to show the latest post (1 only) from all the authors on a wordpress site.

    How do I do this? I have written a custom template for this feature, I have to create my own loop I expect.

    Any help to understand how this is done would be appreciated!

    Jim C

Viewing 3 replies - 1 through 3 (of 3 total)
  • One example

    <?php
    //displays all users with their avatar and one post (title)
    $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 callender

    (@jimcallender)

    I used this example in the end, thanks though

    https://wpsplash.com/how-to-create-a-wordpress-authors-page/

    Hi. I was lookig for a while a solution similar to this one all over the internet and the forum support but I can’t find one solution that fits what I need. Is there a way to limit the post to X amount of authors? I mean, I need to show the latest 4 post published with:

    – Post title and link
    – Author avatar
    – Author extra profile info (I add an extra profile field labeled as “sport”).

    Any solution? Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show latest posts by all authors’ is closed to new replies.