Performancing Metrics

Optimise Your WordPress Themes With Better Author Pages

Recently Ajay D’Souza asked how we made our author archive pages here on BloggingPro. I personally am a big fan of displaying content differently on different sections of blogs and also think that archives should be more informative than be just a collection of excerpts.

Because I personally believe that an ‘Author Information’ block below every entry overkill is, the author archive is the right spot to display more information about every author and also display the entries written by authors in a short and concise way.

Part 1: Adding The Author Description and Gravatar

Creating customised author pages is really simple. Other than some CSS customisation the code for the author description is entirely provided by known and documented WordPress template tags and information gathered from the author profile.

First we need of course a author.php template for this to work and you need to make sure that every author fills in their profile. The code used in following code samples is backwards compatible (to WP1.2!) and makes use of the $ curauth functions documented in the WordPress Codex Author Templates. The email address is protected from spam harvesters.

<p class="listhead">You're in the <b>Author Archive</b></p>

	<!-- This sets the $curauth variable -->
	<?php
	if(isset($_GET['author_name'])) :
	$curauth = get_userdatabylogin($author_name);
	else :
	$curauth = get_userdata(intval($author));
	endif;
	?>

	<div class="post">

	<h2><?php echo $curauth->first_name; ?> <?php echo $curauth->last_name; ?></h2>
	<blockquote><?php echo $curauth->user_description; ?></blockquote>

	<h3>Information</h3>
	<div class="right"><?php echo get_avatar( $curauth->user_email, '56' ); ?></div>
		<ul>
		    <li>E-mail: <strong><a href="mailto:<?php echo antispambot($curauth->user_email); ?>">email author</a></strong></li>
		    <li>Website: <strong><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></strong></li>
		    <li>The avatar to the right is my gravatar. <a href="http://gravatar.com" title="Get your own!">Get your own!</a></li>
		</ul>

You can now easily style this further with CSS.

Part Two: Adding List of Entries Written by The Author

The second part of the author pages is lots simpler and nothing more than a customised loop. Rather a loop without the excerpts.

	<h3>Browse Updates by The Author</h3>
		<ul>
		<!-- The Loop -->
		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
			  <li>
			  <strong><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></strong><br />
			  <small>Filed as <?php the_category(', '); ?> on <?php the_time('j/n Y'); ?> <?php the_time('H:i'); ?> with <?php comments_popup_link('no comments', '1 comment', '% comments'); ?></small>
			  </li>
		<?php endwhile; ?>
		</ul>

That’s It. Almost

All there is left to do now is to add the Previous/Next navigation and provide a fallback option for when the author hasn’t published any entries yet.

	<div class="navigation">
		<div class="left"><?php next_posts_link('&larr; Previous Entries') ?></div>
		<div class="right"><?php previous_posts_link('Next Entries &rarr;') ?></div>
	</div>
			  
		  <?php else: ?>
		  <p><?php _e('No posts published yet!'); ?></p>
			
		<?php endif; ?>
		<!-- End Loop -->
	</div>

It’s as simple as this. You can see the result on my BloggingPro author page.

Categories: WordPress Tips, WordPress Tutorials
Tags: ,

This post was written by . You can visit the for a short bio, more posts, and other information about the author.

Comment with Your Facebook Account

Comments

  1. Ajay D'Souza ) says: 1/19/2010

    Thanks for the article :) I will be implementing this on my blog now.

    And, thanks for the link as well!

    Reply

  2. Rinaldi Syahran ) says: 1/20/2010

    hi Franky, thank you to sharing this things. I must implemented this in my blog

    Reply

  3. -|Gen|K|P|- ) says: 1/20/2010

    I will try soon – thank you

    Reply

  4. Jeffsg says: 1/22/2010

    Cool! But i wonder if these steps would improve SEO?

    By the way thanks for sharing. Great info!

    Reply

    • Franky Branckaute ) says: 1/22/2010

      Who cares about ‘SEO’? A good theme and some basic SEO is all you need. The rest should be content.

      Reply

  5. Jacques says: 6/6/2010

    Thanks for sharing. However, is this possible for pages as well? My site only uses pages – no posts (as CMS). If I open an author page (http://www.gerbera.org/author/landscape-sa/), I see all pages – incl. the ones by admin (like Home, Contact etc.) – as in the loop, posts are queried.
    I tried using , but it gives an error – can’t find anything on displaying pages by author – any suggestions?
    Thanks!

    Reply

    • Franky Branckaute ) says: 6/6/2010

      Jacques, I have not tried it but I would assume that you would have to build query_posts and use the attribute post_type=page.

      Check also the Codex out on Author Parameters.

      Reply

      • Jacques says: 6/8/2010

        Thanks Franky, for fast response! So far I can’t get it to work: I’m using this line:
        “query_posts ‘caller_get_posts=1&author=$curauth&post_type=page&post_status=publish&orderby=title&order=ASC’);” in author.php – it is displayed as plain text on the page, so need to tweak some more.

        Reply

  6. karan israni ) says: 8/8/2010

    Hi,

    I’d like to have exactly the same ‘Archives’ page you guys have here. I want EVERYTHING right from the start with 25 latest updates to archives by date, by category, and lastly by authors.

    But how do i do that?

    I also tried your above thing for author but no luck. My author.php file says:

    Author Template (author.php)

    Oops, no such file exists! Double check the name and try again, merci.

    I have done everything right. Then what’s the error?

    Reply

  7. Jacques says: 8/8/2010

    Have been battling with it now for hours, but I can’t get a list of pages (NOT posts) per author…

    I tried this:
    1:
    2:
    3:
    (as per the great Austin Matzko/Filosofo, here: http://wordpress.org/support/topic/wp_list_pages-gtgt-limit-return-pages-to-specific-author)
    4:

    None of them works… either a synstax error or all pages (from other authors, including Admin) are displayed…..
    Not much documentation to be found either – it is all about ‘posts’, not ‘pages’ – any suggestions?

    Thanks!

    Reply

  8. jenson ) says: 12/6/2010

    i’m looking for an author page template. when i saw the code, it give me some inspiration, starting from made the author page css and make it more unique.

    Reply

  9. Ameya ) says: 4/14/2011

    Franky, thanks a ton for this piece! I was working on author template design for my new theme and wasn’t pretty impressed the way it turned out. I tried way too many layouts and combinations. But this worked pretty well. Kudos!!

    Ameya

    Reply

  10. Dan Jones says: 4/26/2011

    This is a very informative post on adding the author description and gravatar. I had some problems before about adding description and avatar but with this post, I solved them myself. Thanks!

    Reply

  11. Rusty - Fitness Black Book ) says: 4/29/2011

    I hadn’t ever looked into doing that. I’ve spent a lot of my time optimizing the “About Me” page…and that has helped with reader retention…I just haven’t thought of personalizing the posts.

    If I am the only author of the blog do you think it still makes sense to do this?

    Reply

  12. Latoya Petz says: 10/14/2011

    Unquestionably believe that that you stated. Your favorite justification seemed to be at the web the easiest thing to take note of. I say to you, I certainly get annoyed even as folks think about issues that they just don’t recognize about. You managed to hit the nail upon the top and defined out the whole thing without having side-effects , folks could take a signal. Will likely be again to get more. Thank you

    Reply

  13. Saurabh Mukhekar ) says: 11/13/2011

    Thanks for such good article ,It will really help us to get more visitors :)

    Reply

  14. Techpraveen says: 12/24/2011

    My blogs looks cool with this Author Page ;) Thanks a lot for this easy tutorial

    Reply

  15. Hursh ) says: 12/25/2011

    Awesome article..helpful for all…just love this blog n contents :)

    Reply

  16. En fantastisk says: 2/29/2012

    I want to show some appreciation to the writer for bailing me out of this issue. Just after surfing throughout the world-wide-web and getting tips which were not helpful, I figured my life was over. Living without the solutions to the issues you have resolved as a result of this short article is a crucial case, as well as the kind which may have negatively damaged my career if I hadn’t discovered your web blog. Your primary understanding and kindness in handling all the things was valuable. I don’t know what I would have done if I had not come upon such a stuff like this. I can also at this moment look ahead to my future. Thank you very much for the professional and results-oriented guide. I will not think twice to endorse your site to anybody who ought to have tips about this area.

    Reply

Current ye@r *