Support » Fixing WordPress » the_author not working

  • ‘<h3><?php the_author(‘nickname’, TRUE); ?></h3>
    Name: <?php the_author(‘namefl’); ?>
    E-Mail: <?php the_author_email(); ?>
    ICQ: <?php the_author_icq(); ?>
    AIM: <?php the_author_aim(); ?>
    <?php the_author(); ?> has written <?php mdv_post_count(); ?> posts.

    This is the code for my about page template. None of the author data shows up. Infact, the only php that does work is the mdv_post_count(), probably because it’s a 3rd party plugin. If I copy all of this code, however, into a WordPress page and tell it to evaluate the php (via another plugin), it works fine. I would like to go the template route, however, as I am working on a new theme and having a template for the about page just kind of makes it all work better (though, apparently not, in my case).

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ryan Boren


    WordPress Dev

    the_author() must be called within the post loop.

    Ah, thanks. That actually makes sense… So calling the loop on a page without any posts isn’t bad?

    the_author(), as well as all the_author_*() only work when used in The Loop in regards to posts. To get at the profile information of a specific author outside The Loop, you’ll either need to use a plugin/script:

    Or you’ll need to call the internal function get_userdata() in a manner similar to:

    <?php $my_author = get_userdata(USER_ID); ?>

    replacing USER_ID with the numeric ID for the author profile you want to access. Once you call it, you can display the elements of the author’s profile, like this:

    <?php $my_author = get_userdata(2); ?>

    <h3><?php echo $my_author->user_nickname; ?></h3>
    Name: <?php echo $my_author->user_firstname . " " . $my_author->user_lastname; ?>
    E-Mail: <?php echo $my_author->user_email; ?>
    ICQ: <?php echo $my_author->user_icq; ?>
    AIM: <?php echo $my_author->user_aim; ?>
    <?php echo $my_author->user_nickname; ?> has written <?php mdv_post_count(); ?> posts.

    EDIT: Corrected “nickname”.

    Awesome! Thanks a lot!

    I noticed that you used ‘nickname’. This returned nothing. Changing it to ‘user_nickname’, however, worked.

    Thank you very much!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘the_author not working’ is closed to new replies.