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