Wordpress Custom Author Page (author-x.php)
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.
























Té said
am February 18 2010 @ 3:03 pm
Very excited to have found this. I searched a lot and this is the only solution I found. I heard that this will be a feature of Wordpress 3.0 but of course we are needing a solution for 2.9.
I am trying to implement it now but I am wondering if you have an author.php file in which it is implemented that you can share as an example.
If so, please email me at te [at] all [dot] is
Thanks,
Té
admin said
am February 23 2010 @ 5:15 pm
Hi Té,
The code provided in the article should be literally all you need to get going. It checks to see if the author ID page exists for $curauth. If it does, it uses that page. If not, it uses the code provided in the else for the default author page.
Let us know how it worked out for you.
Tim