Authors Page Template For Multi-Author WordPress Blog

As it turns out there is not a simple / native way to have a single page with information on all authors for a multi-author blog with WordPress.

So time to make my first WordPress template….

Starting Point

I used the template-archive.php file from the current theme on the site in question (wp-content/themes/[package]/[theme]/template-archive.php), opened this up and removed the logic within the WordPress loop for displaying the archive links, then changed the name of the file to template-authors.php and updated the template identifier to:

Once this updated file was uploaded back onto the server (into the same directory), an Authors template became available for new pages in the WordPress admin, allowing preview view for debugging.

Fetching Information

Now the annoying bit, getting all of the required information on the users required. After some codex hunting this resulted in the following block of code:

Apologies to any WordPress pro’s if the code is a little hack and slash, I suspect there may have been more useful functions available here to get the same information, but as most native author related functions seem to apply to posts and their respective authors (not pages and users in general) I ended up rooting into the DB directly.

The $wpdb data object along with a few functions from the codex and a quick browse of the database allowed for the fetching of all of the info needed.

Then we just need to ensure we only show author level users which have actually posted on the blog, and actually output the markup:

The markup there is simply stolen from the author bio section in the single.php post template. As a final point, to include the actual content entered in WordPress when setting up a page using the template you need to include:

The Template

I have put up the complete template as a gist on github, to use this yourself you simply need to alter the author bio markup bit to be inline with your own WordPress theme (by replacing the markup entirely or just by adding your own styles in a simple child theme and then drop the template into the folder for your theme.

My version shows name, avatar and author description as well as number of posts which links directly to the traditional user WordPress author page. This is the page I actually made using the template.

About Ingmar Boddington

Codemonkey, Sheffield, UK
This entry was posted in WordPress and tagged PHP, Templates. Bookmark the permalink.