Author Page in WordPress

I was working on a site and wanted to create author pages for all registered wordpress user on the site. After looking at the documatation at http://codex.wordpress.org/Author_Templates. I came up with this code. It will show the author info as well as last 5 post and last 5 comments. You can see the code in action at my author page.

22 Responses To  “Author Page in WordPress”
  • elvis.cat

    you are a star, i’ve been looking for exactly this for 2 days!!

  • Jeff

    Nice work! How do you link to your author page from comments you make?

    • damonledet

      You can edit your comments.php and add this for the author line:
      <a href ="<?php bloginfo('url'); ?>/?author=<?php echo $comment->user_id ?>"><?php echo $comment->comment_author?>

      • muratje

        But if a user is not registered it will return ID=0. But the link will still be visible. You should add a IF ELSE to see if the user is registered or not.

      • muratje

        <?php $theid = $comment->user_id; if ($theid == "0") { ?>

        <?php echo $comment->comment_author?>

        <?php } else { ?>

        <a href ="<?php bloginfo('url'); ?>/?author=<?php echo $comment->user_id ?>"><?php echo $comment->comment_author?>

        <?php } ?>

  • Jeff

    Thanks a bunch – worked perfectly! And as an added bonus, it even made subscriber names link to the home page. SWEET!

  • Ben Parker

    How can I list the coments plus an excerpt of each comment? Is there a way?

    • damonledet

      Sure add comment_excerpt(); to the code in my author demo code. Just make sure it is inside the echo tag or you need to display the comment excerpt with <?php comment_excerpt(); ?>

  • Raphael

    Thanks you very much!!! ;-)

  • Steve Heideman

    Damon, Great post and great code thanks! I have a question for you. When I drop this into my theme, I get a page that is just the bare information and is unstyled…how do I wrap my theme around the author.php to style it correctly?

    • damonledet

      You will have to copy the header and footer information from your theme's page template. Should look like <?php get_header(); ?> and possibly a div tag as well, depends on the theme you are using.

  • AHA

    How can I list the coments plus an excerpt of each comment? Is there a way?

  • Joshua

    Hey, this is great. I have almost everything I need. Now I just need to figure out how to allow visitors to post comments directly on the author.php page. So far I am not finding anything at all. Can you point me in the right direction or refer me someplace that I can find that info?

  • Kelibia

    What should I do with the code ?
    Copy the file into /wp-content/plugins or copy it's content into a new wordpress page ? (after activating php in the site)

  • Phillip

    Hey Damon. Thanks for the code! Just a heads up. The line that displays biographical info of the author outputs a closing anchor tag "" . It doesn't validate due to that, but otherwise this is just what I was looking for.
    Thanks!

  • muratje

    comment_author_email='$curauth->user_email'

    should be

    user_id='$curauth->ID'

    Because if a user changes his e-mail adres, all of the comments will be gone :) (The ID doesn't ever change)

  • ROB

    Damon,

    Think you could help me out? I'd like to add this to my site, but oddly enough this is the first time I'm even glancing at my author page and wouldn't you know it, I don't have one…it doesn't load and I'm baffled. Could you e-mail me?

  • ROB

    Damon,

    Think you could help me out? I'd like to add this to my site, but oddly enough this is the first time I'm even glancing at my author page and wouldn't you know it, I don't have one…it doesn't load and I'm baffled. Could you e-mail me?

  • iwan

    thank you man….its working to my blog….

  • Mike

    Thanks. Worked Great on my site

  • Matt F.

    You rock! Been trying to get an avatar to work with similar code for days. Thank you so much!

Leave A Reply