I've created a custom database request in order to show the most popular posts on a site, now I'd like to publish the author of each of these posts. I haven't been successful in finding a method for retrieving the author name from $post->post_author however, which only gives me the ID of the author.
If it's of any help, here's my custom database call:
$result = $wpdb->get_results("SELECT ID, comment_count, post_title, post_date, post_author FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0, 5");
I've noticed some using "post_author_link" in a couple of tutorials but haven't been able to figure out if it can display the actual author name.
Utkarsh Kukreti answers:
$user_info = get_userdata($post->post_author);
$first = $user_info->first_name;
$last = $user_info->last_name;
Staffan Estberg comments:
Awesome, thanks!