Wordpress

How to Add a Custom Author Profile Page to Your WordPress

When you have a multi-author blog, it is wise to add an author’s profile page to your WordPress blog. An author page bring the readers close to their favorite authors by having some background information listed in their profile. Sadly, most free WordPress themes do not come with a custom author.php which is why this tutorial can be helpful. In this tutorial, we will be showing you how to add a custom author profile page to your WordPress blog.

Because most free themes do not have a custom author.php file, WordPress automatically callback to archive.php or index.php when someone views the author profile page. The problem with that is that it will only list all the posts written by the author, and it provides no personal information about the author.

It is recommended that you copy your archive.php and save it as author.php and then add the codes from the sample below to customize your page matching the theme settings:

<?php get_header(); ?>

<div id=”content”>

<!– This sets the $curauth variable –>

<?php
if(isset($_GET[‘author_name’])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($author));
endif;
?>

<h2>About: <?php echo $curauth->nickname; ?></h2>
<dl>
<dt>Website</dt>
<dd><a href=”<?php echo $curauth->user_url; ?>”><?php echo $curauth->user_url; ?></a></dd>
<dt>Profile</dt>
<dd><?php echo $curauth->user_description; ?></dd>
</dl>

<h2>Posts by <?php echo $curauth->nickname; ?>:</h2>

<ul>
<!– The Loop –>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”>
<?php the_title(); ?></a>,
<?php the_time(‘d M Y’); ?> in <?php the_category(‘&’);?>
</li>

<?php endwhile; else: ?>
<p><?php _e(‘No posts by this author.’); ?></p>

<?php endif; ?>

<!– End Loop –>

</ul>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

This page above will display: Author’s nickname, their website, background information (whatever you put in the description field), and a list of posts written by this specific author. All of the background detail and information will be handled from the Profile page in the admin panel. There are other plugins that will let you add pictures and other extra features in multi-author blogs.

Now that you have created the custom author profile page, you want to make sure that your single.php, and in some cases your index.php both are pointing to the author’s profile link when the name is mentioned. Often when themes do not provide a custom author page, they tend to link to author’s website URL in the “written by” section of each post. So you should search for words like Written by or something along the same line and replace the codes with this snippet, and if you do not have that code, then you want to add the code below anyways in order to provide your users with a link to author’s profile page.

<p>Written by:
<?php the_author_posts_link(); ?></p>

Another great way of letting your users know about author profiles page is simply by listing all authors from your blog on one page, or in the sidebar. We have written an article about this in the past that provides both a raw code solution and a plugin solution, so check out our article on how to list all authors from your blog in WordPress.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s