I'm attempting to display the latest 5 post excerpts from 5 different authors in my blog sidebar. Below is the code I'm using which I tweaked from this thread: Find most recent authors

So far, I've gotten it to work however rather than display each individual author's most recent post, it's showing the author's earliest post. Any ideas on what I'm doing wrong? I've been struggling w/ this for a few days so appreciate any direction you can give. I'm a newbie to PHP but can understand enough to tweak code. Thanks!! You can see it working on my site: wearestd.com

global $wpdb;

$post_IDs = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY post_author ORDER BY post_date DESC LIMIT 5" );

$my_query = new WP_Query( array( 'post__in' => $post_IDs) );

if( $my_query->have_posts() ) {
  while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php userphoto_the_author_thumbnail() ?>
<div id="author_excerpt"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><h4><?php the_title(); ?></h4><br />
<?php the_advanced_excerpt('length=50'); ?></a>
  • try changing DESC to ASC in the sql query.
    – Bainternet
    Commented Jul 6, 2011 at 7:07
  • I tried that, same results
    – Adrian
    Commented Jul 6, 2011 at 7:22

1 Answer 1


Think I've figured it out. Here's the code I used courtesy of this thread on the WP Support Forum. Just replace ()<?php the_author_posts_link(); ?>() with whatever excerpt code you want to use. And Voila!

//list 5 latest authors
$authors =  array();
$count = 0;
'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() ) {
while ($my_query->have_posts() && $count < 5) : $my_query->the_post();
if (!in_array($author_id,$authors)) { ?>
<?php the_author_posts_link(); ?>
<?php $count++;
wp_reset_query();  // Restore global post data stomped by the_post().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.