由于您已经拥有作者的ID,您可以创建一个新的WP\\U查询并获取作者的3篇最新帖子。
以下代码将为您完成此工作,
$getPosts = new WP_Query(
array(
"author" => $user->ID, // This tells the query which author\'s post you want to get.
"posts_per_page" => 3, // This tells the query how many posts you want. In your case, 3.
"orderby" => date, // This tells the query that you want the posts according to their publish date.
"order" => "DESC", // This tells the query that you want to get the latest posts. If you change it to "ASC", then the query will get the oldest posts.
)
);
if($getPosts->have_posts()) {
while($getPosts->have_posts()) {
$getPosts->the_post();
echo "<h2 class=\\"post-title\\"><a href=\\"" . get_the_permalink() . "\\">" . get_the_title() . "</a></h2>"; // Echo the post title as a link to the post on the page.
}
}