WordPress Custom Author Page (author-x.php)

December 18, 2009

It was recently asked in a newsgroup how to make the WordPress author function like the wordpress category page. The format of the category page is category-x.php. Replace the x with the category ID you would like a custom page for (e.g. category-14.php) and when browsing category x the custom page category-x.php is processed instead of category.php.

In my research, I didn’t see a previously implemented way to do this with author.php, so I came up with these modifications to the author.php page:

global $wp_query;
$curauth = $wp_query->get_queried_object();

if(file_exists('author-'.$curauth->ID.'.php'))
{
    include('author-'.$curauth->ID.'.php');
}
else
{
    //Default author page
}

The idea here is to have author.php check to see if author-x.php exists. If it does, include that file. If not, process the default author.php in the else condition.

Stay in Touch!

Subscribe to our newsletter.

Solutions Architecture

browse through our blog articles

Blog Archive