Create Custom Author Profile Page To WordPress Theme

0
1933
views


How to create custom author profile page to WordPress theme? Sometimes we need to add a page to show our blog authors profile in wordpress but most themes don’t have this option and we must install a plugin to do the trick. So here i will show you how to add a custom author page template to any wordpress theme. Just follow this simple steps and you will be fine.

The problem that the most wordpress users get is the conflict on the taxonomies with other plugins so wordpress automatically callback to archive.php or index.php when someone views the author profile page. To avoid that we will create a new file that we will call author.php, It is always 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" class="narrowcolumn">
<!– 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(); ?>

In this page we will list the Author nickname and whatever you put in the description field, plus a list of posts written by this specific author.
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>

You are done!

Extra : You can also add the picture of the Author by using this plugin : Link

To add more parameters, you should refer to the Official WordPress Codex Author Templates page.

Enjoy!


LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.