manually create custom author page

How to Manually Create a Custom Author Page in Your WP Theme

Due to the small number of WordPress blogs that have multiple authors, very few WordPress themes seem to come with a custom author page.

This means whenever someone goes to the author page, WordPress will by default use your archives.php file, or if that isn’t available, then use your index.php file. This generally doesn’t make for a very nice author page because it just displays that authors posts in the same format as your archives.

In order to create an author page, you will want to make a copy of your archives.php file and name it author.php, then upload it to your site via FTP.

Another way to go about it is to go to your theme folder using ftp, create an author.php file and then copy the contents of archive.php file and paste them inside your new author.php template.

You then need to edit the author.php page you just created. It will vary a little bit depending on your theme, but we basically have to redo the post loop for this page.

Note: Some themes will already have an author.php file, so you can just edit that instead of creating another new file.

A typical archive page will call the header, then finish with calling the sidebar and footer. We will be changing the code in between. Here is the code that a standard theme would use between the header and sidebar/footer calls:


<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; ?>


<h3>About: <?php echo $curauth->display_name; ?></h3>


<strong>Website:</strong> <a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a>

<strong>Profile:</strong> <?php echo $curauth->user_description; ?>


<h3>Posts by <?php echo $curauth->display_name; ?>:</h3>



<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>
</li>


<?php endwhile; else: ?>

<?php _e('No posts by this author.'); ?>
<?php endif; ?>
<!-- End Loop -->
</ul>

</div>

This will display the author’s nickname, their website, and whatever is in the description field, as well as a bulleted list of all their posts. Once set up, you can control everything from within your Users panel in your WordPress dashboard. To see a list of other arguments you can get, I recommend checking out the official WordPress Author template.

As an added bonus, if you want your authors name link to point towards the authors page, you can do so with the following code:

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

 

I hope this article helped you learn how to manually create a custom author page without using a plugin.

If you liked this article, then please subscribe to our weekly newsletter to get notified of new WordPress guides, tips, deals and much more.

 

Leave a Reply