2

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.

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

1 Answer 1

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

2
  • Thanks Alex, the problem is that these kind of functions don't display the username when the user has not posted anything. In fact, I want author pages not only for authors but for users too...
    – Job78
    Commented Jul 13, 2011 at 11:09
  • 1
    From what I can tell from working on a project recently if a user is registered they are considered an author in so much they will have a page. You can create an author.php template and go wild with it.
    – Alex Older
    Commented Jul 15, 2011 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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