How To Create An Authors Page

Most themes do not come with a dedicated page for authors. Under the Template Hierarchy, WordPress will instead look for an archives.php template or an index.php template if an author.php template is not found in the theme directory. This means that the summary of an authors posts will be shown in exactly the same way that monthly and category archives are shown.

Although this way shows all of the authors previous posts, it doesn’t tell you much about the author themselves. If you have many authors writing for your blog, you should perhaps consider creating a dedicated authors page for them in order to give them more exposure.

Creating the Authors page

We start by creating a file called author.php. It is important that the file has this exact name as WordPress looks for that before archives.php and index.php.

The most common way of developing an authors page is by using a variable called $curauth (an abbreviation of Current Author). This is the method which WordPress itself promotes.

So to start we need to set this variable so that WordPress can call up the correct information for our user. The code below needs to be placed in our template before the WordPress Loop.

<?php 
 
if(isset($_GET['author_name'])) :
 
    // NOTE: 2.0 bug requires: get_userdatabylogin(get_the_author_login());
 
    $curauth = get_userdatabylogin($author_name);
 
else :
 
    $curauth = get_userdata(intval($author));
 
endif;
 
?>

If the above code doesn’t work (which may be the case if you are using an older version of WordPress), you should try one of the other ways which WordPress suggests.

Once you have added the above code, you can call up any of the functions below:

  • $curauth->aim;
  • $curauth->description;
  • $curauth->display_name;
  • $curauth->first_name;
  • $curauth->ID;
  • $curauth->jabber;
  • $curauth->last_name;
  • $curauth->nickname;
  • $curauth->user_email;
  • $curauth->user_login;
  • $curauth->user_nicename;
  • $curauth->user_registered;
  • $curauth->user_url;
  • $curauth->yim;

* Please note, some of the functions above won’t work in versions lower than WordPress 2.0.

What you add to your author.php file is really up to you. As you can see from the above list, there are a lot of functions you can call upon.

Here is an example of how you could list an authors email on author.php file.

You can email <?php echp $curauth->nickname; ?> at <?php echo $curauth->user_email;; ?>.

You should now have a basic understanding of how to build the author.php file. WordPress have a great example of an author.php file. You can see this example below:

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

Of course, your own author.php will look a little different (since the structure of all themes are a little different). Though the example above should illustrate how easy it is to create an author page.

Some important things to note about the author.php file:

  • Other than setting up the Current Author variable ($curauth), the author.php is very similar to the page.php template. Therefore, I recommend adding the code from the page.php template and stripping it down to suit the author.php page. Please read my article ‘How to create a page shell‘ for more information on this.
  • You will notice that the WordPress Loop is only called upon to display the authors posts. Basic information about the author such as name and email etc should be called outside the loop. The loop itself would not be needed if you are not listing the authors posts within the file, though I believe most of you should use it.

Linking to the Authors page

Once you have created your authors page, you need to link to it within your site. The most useful place to link to an authors page is within an articles information area (i.e. the area which states the date the article was published, what category it was placed under etc).

If you want to link to an author page from your home page, you need to edit your index.php template. If you want to display it on a blog post, you need to edit your single.php template. Lastly, if you want to link to an author page from a page (i.e. a WordPress page not a post), you need to edit the page.php template.

To link to an authors page in any of the above templates, all you need to do is use the the_author_posts_link Template Tag within the WordPress Loop. For example, you could add something like this to your template:

The article was written by  
 
<?php the_author_posts_link(); ?>

Note, the name which is displayed is the name which is entered in a users ‘Display name publicly’ field, which can be found on their profile page. Again, make sure the above tag is used within the WordPress Loop.

Another useful Template Tag is wp_list_authors. This tag can be used outside the WordPress Loop (For example: it could be used in your sidebar or your footer).

<h2>Author List:</h2>
 
<ul>
 
<?php wp_list_authors(); ?>
 
</ul>

The tag simply lists all authors authors in a list. By default, admin is excluded from this list though it is possible to show admin posts as well by setting the exclude_admin parameter to false. Please check out the wp_list_authors information page for more details of the parameters you can use with this tag.

Overview

The authors page is something which is not usually included in themes so if you would like to present more information about your writers you will probably need to create the template yourself from scratch.

Please note, most single author websites and blogs don’t need to create an author template, though it’s worth adding if you regularly have guest posters or if several authors write on the same blog.

As always, please let me know if you are unsure about any of this.

Thanks,
Kevin

About 

Kevin Muldoon is a professional blogger with a love of travel. He writes regularly about topics such as WordPress, Blogging, Productivity, Internet Marketing and Social Media on his personal blog and and provides technical support at Rise Forums. He can also be found on Twitter: @KevinMuldoon and Google+.

14 thoughts on “How To Create An Authors Page

  1. I am getting ready to turn a blog into a community, this post really helped me figure out how to set up my admin pages. thanks

  2. Hello there…

    Thanks for the information. I am a little overwhelmed though, so I will just ask this question in hopes that you can resolve it for me:

    At the beginning of the “author.php” file I find this code:

    My problem is this:

    I don’t want the username of the author to show in the URL that is generated, like this: http://www.WebsiteName.com/author/username

    I would like it to show with the nickname, not the username, in the URL, like this: http://www.WebsiteName.com/author/nickname

    I hope that makes sense. Please do help me if you can…

    1. Hi Chris,

      Yeah I know what you mean. I think the nickname would be preferable to the username in most cases (particularly if someone uses something like Davey1982 or something like that).

      There is no easy way to do what you are asking but it is possible (I haven’t tried it myself though).

      In the wp-includes/author-template.php file, which is the file which decides the url of your author page, WordPress appends either $author_id or $author_nicename to the url. The nicename string is used with those who are using the mod rewrite (i.e. seo friendly urls).

      According to a comment from anonymous left in this forum thread two years ago, you need to replace the nicename string with display_name.

      As you can see from the suggestion, there are 3 or 4 templates you need to update.

      It doesn’t look like it would be too difficult to do so if you really need this for your site I would give it a go.

      Be aware. WordPress uses either the ID or username of an account because it can only be changed via the database and not through the wordpress admin/profile area. The display name field can be changed by the user at any time. It can also include spaces so you may get %20 in urls frequently. Not sure if this is a concern for you though.

      Let me know how you get on :)

      kevin

  3. Thanks Kevin… It is clear (although not appealing) now. :-)

    I appreciate your help.

    What I am thinking now though is to just create a new user with a login username that is more appealing than the Admin login username. Then, I can give this new user Editor level permissions, and this way I can mask the Admin user ID name from appearing in the Archives URL (which is the whole thing I am trying to get at), and at the same time protect the Admin username ID.

    Thoughts?

    1. Hi Chris,
      If it’s just the admin username you want to change then go into phpmyadmin, scroll to wp-users and then modify admin (id 1). Just change user_login from admin to Chris or whatever.

      :)

      1. No, sorry if I wasn’t clear. I am not simply trying to change the username (as I could just create another Admin, and then just delete the first, that is easy), rather, I am trying to mask the login name by having another name show up in the author archive URL (like the nickname, or first and last name, but NOT the username for login). Make sense now?

  4. Got my author page working no problem but I have a category Id like to exclude from the loop, the moment I use query_posts though it shows other authors on my author page (which obviously I dont want).

    Is it possible to somehow throw a $curauth argument in the query posts?

    1. nvm in case anyone needs to know this I had a brain cramp

      query_posts(‘showposts=&cat=-364,-365&author=’ . $curauth->ID);

      1. killer, Walks. thats exactly what I was looking for. Except my authors write pages instead of posts, so i did it like this

         'page',
           'showposts' => 10,
           'author' => $curauth->ID
           );
           $posts = get_posts($author_articles_list);
           if ($posts) {
           foreach ($posts as $post) {
           setup_postdata($post);
        ?>
            
            <a href="">    
            
            <a href="" class="readmore">Read more... 
        		
        
        
  5. Hi Kevin,
    Thanks for the tut. I was wondering if you could shed some light on an issue I’m having. I have included this :

    into the loop for the page template I’m using. It seems to be pulling one author in particular and providing a link to their author page but not reflecting the logged in author. Any ideas?

Comments are closed.