If your blog features more than one author, you may want to jazz it up a bit by adding author pages devoted to each contributing author. Dedicated author pages can make your website stand out and give each individual author their own space to share a little more about themselves. Adding other pages will not only provide details for each contributing author, but it will also help expand your blog by offering more information to your viewers.
Adding file for the author page
Very few WordPress themes come with author page. So whenever a user visit the author page WordPress will search for the auther.php if it is not found then WordPress will use archive.php file also if the archive.php file is not available index.php is used to display the content.
With the skeleton framework coding in place, you are ready to add in the content for your author page. Search for the section of code that displays the set content message. In order to replace this section of code with a code containing the author bio, you will need to consider the type of information you want to include on each author’s page. Below is a sample of information that you may want to include in each author page you will be setting up:
- Author Name
- Author picture or avatar
- Author’s personal or professional website link
- Author information or biography
- List of post written by the author on your specific website
Here is the sample code:
<?phpget_header(); ?> <div id="content" class="narrowcolumn"> <?php //This sets the current author information to $curauth variable $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?> <dl> <dt>Website</dt> <dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd> </dl> <div id="author-info"> <div id="author-avatar"> <?php echo get_avatar($curauth->user_email); ?> </div><!-- #author-avatar --> <div id="author-description"> <h2>Author Name: <?php echo $curauth->first_name . $curauth->last_name;?></h2> <?phpecho $curauth->description; ?> </div><!-- #author-description --> </div><!-- #author-info --> <h2>Posts by <?php echo $curauth->nickname; ?>:</h2> <ul> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <li> <a href="<?phpthe_permalink() ?>"><?phpthe_title(); ?></a>, <?phpthe_time('d M Y'); ?> </li> <?phpendwhile; else: ?> <p><?phpecho 'No posts by this author.'; ?></p> <?phpendif; ?> </ul> </div> <?php get_sidebar(); get_footer(); ?>
You can now create additional code snippets for each author, allowing all of your contributors to have their own author page set up. You may want to include similar information for each author, or you may want to set up each author’s pages differently – depending on the preference of you and the author. If you want to setup different view and different layout for different author just use author nick name with the author template file. e.gauthor-{nicename}.php. That means if there is an author whose nick name is ariful then the template file name will be author-ariful.php.
You can also use author id instead of nickname like if the id of the author ariful is 11 then the template file name will be author-11.php.
So if there is no specific template file available for an author it will use author.php template file. WordPress first searches for the author-{nicename}.php template. if it doesn’t exist WordPress will search for author-{ID}.php. If none of them exists then author.php template is used.
Summary
If you are familiar with html code, you may want to add other design elements to enhance the author pages. The above information will help you create the basic author page; however, the type of author page you can create does not have to be limited to the basics. With understanding of html, you can add individualized backgrounds, custom fonts and other designs to distinguish each author’s page and show off their originality. You can also visit the official WordPress author template page for more details.