
We’ve learned how to add an author bio to single posts and revamp our comments with gravatars. Now, it’s time to take this one step farther.
We’re going to create a template page for all of our authors.
This can be useful if you have multiple authors on your site and want to have a page that lists all of them. It’ll let users get to know each author a little before diving into their posts.
Note to my theme users: Of course, all of this stuff is being built right into the development versions of my themes. So, you can look forward to some of this stuff being added in future updates.
Here are the steps required in doing this:
- Give your authors some biographical information from your WordPress dashboard.
- Create a template page to display each author.
- Write a new Page and save it with your new template.
Oh, and you might want to get a gravatar if you don’t have one.
Setting up your authors biographical information
Well, there’s no use in having an authors page without showing some biographical information along with each author.
Log into your WordPress dashboard and click on the “Users” link. From there, you can select any user you want to add information for. Scroll down to the bottom of the screen, and you’ll see a section named “Biographical Info.” Just type whatever you want about yourself or a particular author.

Click “Update Profile” to save this new information. You’ll probably want each author of your blog to write a short blurb that suits them.
Creating the authors template
The first thing we need to do is name our template (very important!) and get the header file. I’ve named this template “Authors” for simplicity.
<?php /*
Template Name: Authors
*/ ?>
<?php get_header(); ?>
Then, we need to set up a basic loop to show the title and content of the page. This way, you can still write a little describing the page later.
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<div class="post">
<h2 class="section-header">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h2>
<div class="entry">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; endif; ?>
Now, we can move on to the backbone of this template page, which will show all of our author profiles.
Before we display any information, we need to actually grab the information from the database. I tried to comment this well enough for everyone to reasonably understand what’s going on.
<?php
// Get the authors from the database ordered by user nicename
global $wpdb;
$query = "SELECT ID, user_nicename from $wpdb->users ORDER BY user_nicename";
$author_ids = $wpdb->get_results($query);
// Loop through each author
foreach($author_ids as $author) :
// Get user data
$curauth = get_userdata($author->ID);
// If user level is above 0 or login name is "admin", display profile
if($curauth->user_level > 0 || $curauth->user_login == 'admin') :
// Get link to author page
$user_link = get_author_posts_url($curauth->ID);
// Set default avatar (values = default, wavatar, identicon, monsterid)
$avatar = 'wavatar';
?>
Now for the actual display of the author profiles. We’ll just show each author’s gravatar, display name, and description with the gravatar and display name linked to the author’s archive page.
I’m treating each profile as a post, so I won’t have to add additional CSS to my stylesheet to get them to display properly.
<div class="post">
<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>">
<?php echo get_avatar($curauth->user_email, '96', $avatar); ?>
</a>
<h3 class="post-title">
<a href="<?php echo $user_link; ?>" title="<?php echo $curauth->display_name; ?>"><?php echo $curauth->display_name; ?></a>
</h3>
<p>
<?php echo $curauth->description; ?>
</p>
</div>
After that, we just need to close off everything we’ve opened.
<?php endif; ?>
<?php endforeach; ?>
<?php get_footer(); ?>
Just save this file as “authors.php” and drop it in the folder of the theme you’re currently using. You have to save this before moving on to the next step.
Writing our authors page
Once the above is done, all we have to do is create a new page. We go back into our WordPress dashboard and click on “Write > Page” to do this.
Give your new page a title; something like “Authors” might work. Maybe write a few sentences describing what this page is for.
For the most important part (you can’t forget this), find the section titled “Page Template.” There’ll be a drop-down list of page templates to choose from. Select the “Authors” template.

Once that’s done, you can publish your new page and view it on the Web.
Other things you can display
There are a few other things you can display as well. For example, you might want to give a link back to the author’s personal website or show their email. From the author templates page in the WordPress Codex, there’s a list of things you can show (I’m sure they don’t mind me borrowing them for this post).
These things are all configurable from the user profile edit page. Just make sure you use them after the line:
$curauth = get_userdata($author);
from the above code.
$curauth->aim;
$curauth->description;
$curauth->display_name;
$curauth->first_name;
$curauth->ID;
$curauth->jabber;
$curauth->last_name;
$curauth->nickname;
$curauth->user_email;
$curauth->user_login;
$curauth->user_nicename;
$curauth->user_registered;
$curauth->user_url;
$curauth->yim;
Go ahead and create your authors template
This should be a mandatory page for multi-author blogs. It will let your users get to know each author a little better.
As mentioned earlier, I will be incorporating this template into my themes, so if you’re using one of them, look forward to this feature in the next update.
If you need help implementing this, just stop by the support forums because it’s much easier to post code there.
I have done exactly what you have told here. But when I publish the page, I just get the Author as page title and nothing is shown…
Justin it does show other authors detaisl except admin. And I am admin here. I created a new user with riole as author and it is showing the detaisl on the page.
You continue to rock all the time. I’m sure Project M will be the next big WordPress thing soon at this rate.
I don’t think I’ll be making use of this technique anytime soon though. I don’t yet run a multi-author blog, but if I do launch a webcomic with my friend sometime later this year or the next, this will definitely come in useful.
Bookmarked in del.icio.us!
techiezone
I just tried it on another blog, and I can see what you’re talking about. I’ll try to find a fix for this tonight.
BoltClock
Thanks. It looks like there might be a small bug with it right now, but I should have a fix up when I get home from work.
Great tutorial. I run a multi-blog site and I was just thinking of how to display “The Team” that’s behind the site. Now I know, thanks!
IndieLab
Thanks. Let me know when you get it up.
techiezone
For some reason, WordPress wasn’t giving the default user login name of “admin” a user level. It was just blank. Anyway, I updated the code, so it should work now.
Thanks Justin, very useful tutorial. I was eagerly following the series “Doing more with Gravatars” and found them really helpful.
I’m planning to run a multi-author blog next year and this will be a great reference.
$curauth = get_userdata($author);Loll, so do you mean I can display the entire profile contents? Can I add additional hooks such as author posts and author comments on that certain blog?
J Mehmett
The
get_userdata()function is really useful for multi-author blogs. You should be able to add additional author info fairly easily. You might have to look up how to get the number of comments and posts though. I don’t know it offhand.I’m also putting together a widget for this to be included with my themes.
I think I might have one or two more articles that could be useful with gravatars too.
Justin, I like your ideas, man.
The only limit of Implementing Gravatars with WordPress theme might be the sky limit.
nifty. i’m gonna try this out.
Thanks a lot Justin.
Does it matter if I created all the users, because I’m just getting my own picture + bio as many times as I have authors.
Other than that, it seems cool
J Mehmett
I always say, “The only limit is your imagination.”
Jenny
Let me know how it works out for you because I’m implementing this into my themes too.
techiezone
No problem. It looks like you’ve got it working. By pointing that out, you’ve helped me see some other code bugs in my themes that’ll definitely help in future updates.
Thomas
It shouldn’t matter. From everything I can tell, the code should display all users that have any authorial privileges.
Drop your code off in the General Discussion part of the forums, and I’ll have a look at it to see if there’s anything missing.
I’ve done as requested
Great tutorial, I just found your site and will definitely be coming back….I really like your writing style.
I am going to add a link to this article and your site on my blog.
I think there is an extra “=” in the line below:
“// If user level is above 0 or login name is “admin”, display profile”
I removed it and then the admin author showed up for me.
this is an awesome tutorial, but I am using the register plug plugin to extend the user fields, maybe you can show us also how to get those fields into the authors page too? http://wordpress.org/extend/plugins/register-plus/
Also a little help to get some stats about a user would be great, either using built in wp functions, i.e. numer of posts written, or number of comments , anything you can think of. otherwise maybe combining this with the wp stats plugin of lesterchan? http://lesterchan.net/portfolio/programming/php/#wp-stats
There are also another way to show a avatar without using the Gravatar service.
<img src="/wp-content/themes/yourtheme/avatars/.jpg" height="95" width="95" alt="" />Addenum. The avatar file must be named exactly the same as the user login name.
The PHP code was stripped in my last comment.
See: http://www.matblogg.se/avatar_local.jpg
This is fantastic!
I’ve implemented this successfully, but i’m listed right at the top (because i’m the admin). Is there anyway for the admin to be listed with the other authors alphabetically?
Joseph
Check out Author Templates: Using Author Information.
You should be able to change this:
to something like this:
If you need any help with the code though, just stop by new support forums because it’s easier to post code there.
hi..i cannot find any page templates section..just page parent on top of page order
nice tutorial. Thank you very much..
Hey Justin,
Quick question…..how would you go about excluding the “admin” user from your query? I don’t mind showing people with admin privileges, but just want to hide the one “admin” user.
Great Work,
you have been a saviour a few times…
@Travis
I am also wondering the same thing. What I did try dident work. I am not a progammer so I am thinking there has to be a relatively easy solution.
By the way thanks for a great tutorial, I searched high and low for something that would explain the author page. I was able to get the job done with this. Now if I can only get a couple of authors to join…
@Mike
The solution I came up with was simply deleting the “admin” user altogether. You can do this if you have and are logged in as any other user.
Give that a try, if you don’t require an admin user.
Thanks for the idea. I dident know you could remove the admin, but when you think about it, who really needs an admin? Why bother with two accounts, when you can just have your own account with admin privileges.
Quick question: Would this exclude those set to ‘contributor’ as they do not have author privileges? I need to include both authors and contributors and treat them both as authors for the purpose of the author page. The only difference between them, for our site’s purposes, is editorial review prior to publishing.
Thanks for the clarification.
Oh, and thanks for the tutorial! This is going to come in handy.
Travis, you can also fix this by editing one line of code:
change:
if($curauth->user_level > 0 || $curauth->user_login == ‘admin’) :
to:
if($curauth->user_level > 0 && $curauth->user_login != ‘admin’) :
Thanks for this.
Just a tip to anyone who wants to exclude not only the admin user but also certain specified other users too (as I did). You can do this by amending the query as below, entering an array of user ids to be excluded:
$query = “SELECT ID, user_nicename from $wpdb->users WHERE ID NOT IN (1,19,23) ORDER BY user_nicename”;
@katherine,
I’m getting a syntax error w/ your “WHERE ID NOT IN” like.
Thoughts?
hoss9009 it’s the curly brackets from Katherine’s code… replace with ” around and it works perfectly
hi,
i have a problem i would like to show just one author and not a list of authors…how create this ?? can i delete the loop (foreach)?? and i would like to display extra fields with the plugin register plus can you help me…
stefan
This is great.
But I cannot get pagination to work. So there is just too many authors on one page.
Is it too much trouble for you to post the code that would get the All Authors template to use the same pagination as normal posts.
Thanks
@Paul, did you get the pagination to work? I can’t seem to get mine to work either.
Nice hack, thank you.
I’m using it on my website, just a question: since I have more than 500 users, is there a way to paginate them?
Thanks again for the hack,
ciao!
Hi Justin,
thanks a lot for this great script. Could you please also explain how to add pagination to it?
The thing is that I have hundreds of authors, and it is not very handy to display them all on one page. Thanks a lot in advance for your reaction.
I have been scouring the internet for this exact post. I was just about to break down and try to code my own “authors loop,” thanks so much for this very useful bit of code!
@Justin, great author template – just what I was looking for.
@Katherine – very nice tweak indeed.
Thank you all.
Hi! This is very useful! Thanks!
Just a question… Is it possible to order the authors by last name? I tried to use
“ORDER BY last_name” but it don’t work…
Thank you
Is there a way to order by AIM, as well? I’m thinking not, because I’ve checked my database and there’s no clear field where that content would be..
Great tutorial. Is there anyway to add this to a current page under the content?
That was an awesome tutorial. Very well written. I made an authors page for my site, I was not sure how to get the templates working, and this helped me out.
Thanks a lot again.
Hi,
I got this working but I was wondering if there was a way to display an author page where the user had posted to certain categories.
Cheers
Easy one for me, and i put randomly generated list by editing db query, so instead of “ORDER BY user_nicename” i put “ORDER BY rand()” and that’s it. I have one question, and that’s how can i get in author list number of posts by author. I can do this on single page on author box, and on author page (like site.com/author/foo) but here i cant get it to work.
Thanks heaps for this Justin.
Perfectly explained…clearly and simply!
Just what I was looking for. I am pretty new to Wordpress and this really helped me find a solution fast. YOU ROCK!
Thank you for the code, it is excellent. I am trying to get this to sort the users by last name, but whenever I change user_nicename to last_name it fails. Any thoughts?
By the way, I get an error page when I try to access your forum.
Does anything change with this setup w/ wp_users_query?
Hi
I have listed all authors on my page. But now what I want to do is when I click on one author it should take me to that author’s individual page.
Now it is taking me eg. example.com/author/test-author (Here author name is test author). But what code should I put in so it displays this particular author’s information.?
So how can I do that? It would be a great help.
Thank you
Sanjay
hello Justin!
thank you for all the great info you have posted.
I have a question regarding the text background for the authors page. I inserted the following code:
to place a white-ish background behind the author info text, but the background stretches all the way up past the header and covers the menu tabs. I was wondering if you could provide some insight on how to keep the background for the text just behind the Page title and the info that follows
thanks!