logo

$4
Retrieve author name from $post->post_author (or other $post val)

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.

Staffan Estberg | 08/29/10 at 3:51pm | Edit


(1) Possible Answers Submitted...

  • avatar
    Last edited:
    08/29/10
    4:06pm
    Utkarsh Kukreti says:

    $user_info = get_userdata($post->post_author);
    $first = $user_info->first_name;
    $last = $user_info->last_name;

This question has expired.





Current status of this question: Completed