get the username of a user in his author page

I’ve implemented this code inside my author.php file, in order to display the username of the author:

<?php printf( "<h4>The blog of<a href='" . get_author_posts_url( get_the_author_meta( 'ID' ) ) . "' title='" . esc_attr( get_the_author() ) . "' rel='me'>" . get_the_author() . "</a></h4>" ); ?>

It displays correctly the username of a user who has posted articles, but unfortunately displays another username when the user hasn’t published anything.

Read More

Is there a way to solve that ? Thanks for your help !

Related posts

Leave a Reply

1 comment

  1. Take a look at the codex page on author templates – Author Templates

    Especially the $curauth object.

    In order to display author information on your author page, edit your author template file – author.php so that it figures out which author is being viewed, and retrieves all the information about the author from the database (i.e. the information entered in the User administration screen of WordPress).
    This is done by setting up a variable called $curauth (Current Author).

    Quote Source – WordPress Codex / Custom Author Information