Get Each user recent post in wordpress

To do this we will need to do 2 queries:

1) Get a list of all the users on the site via wp_user_query

2) Get posts from all the users using wp_query

The code:

$user_query = new WP_User_Query( 'Author' );

if ( ! empty( $user_query->results ) ) {
 foreach ( $user_query->results as $user ) {
  echo '<h2>' . $user->display_name . '</h2>';
  $query1 = new WP_Query( 'posts_per_page=4&author_name=".$user->display_name );
  while ( $query1->have_posts() ) {
   $query1->the_post();
   echo "<p><a href="'.get_permalink().'">'.get_the_title().'</a></p>';
  }
  wp_reset_postdata();
 }
}

It’s not tested but it should display like:

Author 1:
– Post 1 Post 2 Post 3 Post 4

Author 2:
– Post 1 Post 2 Post 3 Post 4