Simple Guide to Creating Custom Author Templates With WordPress 3.0

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:

FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.

By downloading this ebook I consent to occasionally receive emails from WPMU DEV.
We keep your email 100% private and do not spam.

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:

<?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;
?>

Walter’s Bio:

<?php echo $curauth->user_description; ?>

How you customize the template is 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.

Tags: