Simple Guide to Creating Custom Author Templates With WordPress 3.0

Custom author templates can be a great enhancement to a multi-author blog where you want to implement unique styles for one or more blog authors. WordPress 3.0 makes customizing author templates easier than ever. It’s now similar to the way you might create a unique category template: ie. category-news.php and it’s new to 3.0.

How to include a custom author template file:

WordPress first will look for one of the following:
author-{nicename}.php
author-{id}.php

If neither of these are present, it will then look for author.php followed by archive.php and then index.php.

Step 1: Create the author-{nicename}.php file.

The easiest way is to copy the archive.php file and then add or change whatever you want to in that file. Save it as an author template file, ie.:

author-walter.php

Step 2: Upload the file to your theme’s folder.

Now you can check out your custom template by visiting the author’s archive you customized. For example:

http://yourdomain.com/author/walter/

This is an example of a custom author template page added to the BuddyPress default theme:

The above example uses the basic archive.php template for BuddyPress with an added tag to include Biographical Info for the user at the top before the posts. Include this snippet in your archive.php file to show author info:

1
2
3
4
5
6
7
8
9
10
11
12
<div id="authorbio">
<?php 
if(isset($_GET['author_name'])) :
    // NOTE: 2.0 bug requires: get_userdatabylogin(get_the_author_login());
    $curauth = get_userdatabylogin($author_name);
else :
    $curauth = get_userdata(intval($author));
endif;
?>
<h4>Walter's Bio:</h4>
<p><?php echo $curauth->user_description; ?></p>
</div>

How to customize the template will be up to you. You can add particular CSS classes, unique backgrounds, a quick bio at the top of the page, custom author information, or anything you want to make the page different from your default archives.

Further Details and More Information

Please note that the custom author templates will only work with WordPress 3.0 and will not be applicable to earlier versions. You can find more detailed information about how to create unique author templates, tags you can include, and a sample template in the WordPress codex section on Author Templates.

Comments (4)

Participate