How to Create An Author Information Box For Multi-Author WordPress Blogs

Welcome to another edition of the Smashing WordPress tutorials (first, second). Enjoy this one!.

If you like this post, please consider Stumbling or bookmarking it on Delicious! :D

If you run a multi author blog, you must also have an author information box beneath or at the top of posts, telling the reader about the author, right?

For example, take a look at these three examples below:


A List Apart (right at the end)

And

And


Guess…

This can be done using a plugin, but doing it using code is really easy and fun, and quick too, and that’s what this tutorial is about.

The Idea

We’re going to display the author’s picture, and a little information about them next to it. All this is going to be done using template tags (ah, how I love them!).

Let’s Start

All the stuff we put is going to be in a div, which you can position anywhere you want (preferably below the post). Here’s the code for the whole thing:

<div id="authorbox">
<strong>About the Author</strong>

<div>
<img src="/images/<?php the_author_ID();?>.png" alt="Author Image" id="authorpic"/>
</div>

<div id="authorbio">
<?php the_author_description();?>
</div>

</div>

Now, we start off by opening a new div, to host all the contents. Then, we add a bolded (you can change this) ‘About the Author’ piece.

The Avatar

Next comes the avatar, in a div of its own. I’ve placed my avatar in the images folder in my home directory. Now, in that folder, there will be the avatars of several different authors, right? To find the one I need, I use the the_author_ID template tag to generate the user ID of that particular author (you can find this by hovering over the user name on your Users admin page). Thus, the image’s filename looks something like 2.png (with 2 being the user ID).

For this to work, create avatars with the user IDs as the file names, (such as 1.png and 24.jpg), and drop them in the specified folder.

The Bio

Now comes the biography. We take the information in the ‘Biographical Info’ dialog box on the Edit User page of your WordPress administration. For this, we use the the_author_description template tag. This will pull the information out of the ‘Biographical Info’ dialog box, and paste it here.

And of course, you give it its own classed div, to help you style it.

What’s Next?

What’s next is for you to style your author box using CSS, which shouldn’t be hard :)

Spruce it Up!

You can use a whole truckload of template tags in your author information box. For example, here are some author and post related stuff you can put in there:

  • The author’s website – using the the_author_url template tag, you can put the author’s website URL in the author box. This URL is defined in the user’s profile.
  • The date – you can display the date of the article by using the the_date template tag

Your Thoughts

Has this tutorial helped you? We’d all love to know! :)

If you liked this post, please consider Stumbling or bookmarking it on Delicious! :D


If you liked this post, consider subscribing to the RSS feed (what's RSS?) to get updates on new blog posts.
You can get our latest articles on blog strategy, design, WordPress and the like delivered to your inbox, free of charge. Just enter your email below:

13 Responses

  1. 1

    Damn, why didn’t I think of writing this? :)

    Now I know why you asked me for some sites with author info boxes….

    Good tut, anyway. Though I don’t know if it is easy for intermediate users, I hope it is.

    September 14th, 2008 at 3:57 pm
  2. 2

    I guess you should point out the plugin too…for those noobs who run from hand coding like I used to do in the past…so they may have no difficulty applying this function in their blogs….you know…everyone is not as good as you are ;)

    September 14th, 2008 at 6:11 pm
  3. 3

    Great post. The trick with the image names in particular was very clever! :)

    On Pro Blog Design, the system was set up to handle loads of different guest authors. The only registered account on the blog is still mine. To get other people’s details in the author section, I use two custom fields on each post (And if the custom fields are empty, it uses my details).

    It works for me because I don’t have to make every author register an account (Considering they may only be making the one post on the blog), and I edit all the posts first anyway. :) )

    September 15th, 2008 at 1:41 am
  4. 4

    Other alternative is use gravatar for author image by replacing img src with gravatar image of the author. Like gravatar for this comment.

    September 15th, 2008 at 2:23 pm
  5. 5

    i am a newbie to wordpress. this was a really interesting post.

    September 17th, 2008 at 1:50 am
  6. 6

    Woo-hoo! Great tips to add another feature to the Moose’s blog.

    Great site, by the way. Easy to read and easy on the eyes.

    I’ll be subscribin’ now, me thinks

    September 17th, 2008 at 7:19 am
  7. 7

    Great site. Thanks… :)

    December 11th, 2008 at 12:14 pm
  8. 8

    outgoing influence buddy. trust to get more from your side :)

    December 28th, 2008 at 6:45 pm
  9. 9

    Thank you for that cool tutorial. Is there any way to insert that div container into my feed?

    January 26th, 2009 at 3:11 am
  10. 10

    I too would love to know how to do this in RSS feeds!

    thanks for the great info!

    May 29th, 2009 at 3:16 am
  11. 11

    Great info, very useful! This is exatcly what I needed!

    June 19th, 2009 at 1:58 am
  12. 12

    Great work admin!

    November 14th, 2009 at 2:06 am

Leave a Reply?