WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a page template for the front page of a site I am building using WordPress. I am displaying the 3 latest posts on this page and all works fine except for the display of the author of the post. I am using the following code

        if ($recentposts) 
            foreach($recentposts as $post)

        <div class="fifthFloat">
            <h3><a href="<?php the_permalink() ?>" rel="bookmark" 
                     title="Link to <?php the_title_attribute(); ?>">
                        <?php the_title(); ?></a></h3>
                $postContent = $post->post_content;
                if(strlen($postContent) > 50)
                    $postContent = substr($postContent, 0, 
                             strrpos(substr($postContent, 0, 60), " ")) . " ...";
                echo $postContent;
            <p>Posted <?php the_time("jS M Y"); ?> by <?php the_author(); ?></p>


and I have also tried the following

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

but both result in an empty string.

share|improve this question
up vote 2 down vote accepted

Any reason this is commented out?


This function setups global variables for current post and author data is pulled from one of those.

share|improve this answer
hahaha now I really feel like an idiot!!! Thank you – Simon Fox Dec 16 '10 at 8:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.