Untitled UI logotext
Solutions
WebsitesEcommerceMobile AppsWeb AppsProduction Support & Maintenance
Our work
Company
About usBlogPodcastContact us
Book a free consultation

Wordpress Custom Author Page (author-x.php)

Olivia Rhye

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.

Ready to start a project?

Book a free consultation
Untitled UI logotext
Our work
About us
Blog
Careers
Submit a ticket
Agency Partnerships
Contact
© 2024 fjorge. All rights reserved.
Privacy