List authors from category by date of latest post with titles
-
Hello,
So i need to list 3 authors from category “blogeri” by date of latest posts with author’s avatar and title of respective latest post that should be linked to the story.
Below is compiled code that I have found here that do everything I need except the post title part. This snippet shows number of total posts of an author. What I need is to show latest post title of the respective author.
<ul> <?php //List of users sorted descending by date of lastest post written by user $uc=array(); $blogusers = get_users_of_blog(); if ($blogusers) { foreach ($blogusers as $bloguser) { $user = new WP_User( $bloguser->user_id ); if ( !empty( $user->roles ) && is_array( $user->roles ) && ( in_array('blogeri',$user->roles) ) ){ $userpost = get_posts('showposts=1&author='.$bloguser->user_id); $uc[$bloguser->user_id] = ''; if ($userpost) { $uc[$bloguser->user_id]=$userpost[0]->post_date; } } } arsort($uc); $i = 0; foreach ($uc as $key => $value) { $user = get_userdata($key); $post_count = get_usernumposts($user->ID); if ($post_count && $i < 3) { $author_posts_url = get_author_posts_url($key); echo '<p class="classul">' . get_avatar($user->ID, 46). '<a href="' . $author_posts_url . '">' . $user->user_firstname . ' ' . $user->user_lastname . '</a> (' . $post_count . ')</p>'; } $i++; } } ?> </ul>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘List authors from category by date of latest post with titles’ is closed to new replies.