Skip navigation

Using Author Template Tags Outside of the WordPress Loop

WordPress allows you to create a custom Author web page for your WordPress blog. You can make this page look like anything you want, customized to the author or with just some tidbits about the author added to the page to help readers learn a little more about the person behind the post.

I had very specific ideas about the look and what information I wanted on the author page for my new WordPress blog. Since I am planning on working with a variety of authors, I wanted to showcase each author’s contact information, home website, a description or bio of the author, and then a highlighted list of the articles the author has published on the blog. This turned into a bit more of a project than I planned, so I thought I would share my techniques with you.

If you want to create a custom author page in WordPress, start with the WordPress Codex article on WordPress Custom Author Template Files, good advice on how to create a custom author template file.

Typically, most WordPress blogs have only one author, therefore, most WordPress Themes, if they include a byline or author information, do so as plain text. WordPress has a template tag that can replace the standard author template tag to turn the author’s name into a link. Click the link and the visitor is taken to a web page that generates a “search result” listing of posts by that author. Very simple and automatic.

To create such an author link, Change the commonly used <?php the_author(); ?> template tag to:

<?php the_author_posts_link('namefl'); ?>

A link with the name of the author will be automatically generated, such as:

Lorelle VanFossen

You can add this template tag author link as a byline or in the post meta data section of your posts. When clicked, the link will go to the index.php template file to generate a list of posts written by that author, or, if you have it, use the author.php template file which you can customize to make it look however you want. I had very specific ideas on how I wanted my custom author template page to look.

Because I don’t do simple things like rely upon WordPress to just generate the author’s page by default, I wanted to create a customized author page with contact information and a biography for each author. I created a customized author.php template file which WordPress seeks automatically when an “author link” is clicked.

Remember, when working with default template hierarchy files, you don’t need to do anything. WordPress will search through a set of template files and if it finds it, it will automatically use it. If it doesn’t, it goes back to the default, which is the index.php template file. So, if it is there, it uses it. For more on how template files work in WordPress, see Stepping Into Templates.

On my custom author.php template file, I wanted the title to read Articles by Lorelle VanFossen, or whoever the author is. I also want a short list of the author’s main website, email contact, and biography, helping readers learn more about the author. Then the WordPress Loop would begin, generating a list of posts by that author.

The template tags and text I wanted to use should have looked like this:

Articles by <?php the_author(); ?>
Author Website: <?php the_author_url(); ?>
Author Email: <?php the_author_email(); ?>
Author Bio: <?php the_author_description(); ?>

However, I have a little problem.

The template tags I wanted to use work only within the WordPress Loop, a bit of PHP code that gathers information from the database and displays it. By using these template tags outside of the Loop, the key that starts the process of gathering information from the database isn’t initiated, so there is nothing to find. They don’t work.

If I used these template tags within the WordPress Loop, so they will work, this information would be generated on each and every post returned written by the author. That’s too much duplicate information. I wanted to list this information separately from the post search results, and to only display once. Yet, these tags only work inside the Loop. I had to find another method of calling the information from the database outside of the WordPress Loop.

I found the solution in the WordPress Custom Author Template Files article on the WordPress Codex.

It begins by adding a GET call to the database (to GET data) placed just below the call to the header in the author.php template file. It creates a kind of mini-loop, gathering information about the author from the database and assigning it to variables which can then be used outside of the WordPress Loop:

<?php get_header(); ?>
<?php if (have_posts()) : ?>
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin(get_the_author_login());
else :
$curauth = get_userdata(intval($author));

In the area where I want the information about the author gathered from the database to display, I added the following, totally replacing the Loop template tags I wanted above:

<h2 class="posttitle">Articles by <?php echo $curauth->display_name; ?></h2>
<div id="authorinfo">
<p><strong>Author Website:</strong> <a href="<?php $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a><br />
<strong>Author Email:</strong> <a href="mailto:<?php echo antispambot($curauth->user_email); ?>">Contact Author</a><br />
<strong>Author Bio:</strong> <?php echo $curauth->description; ?></p>

Note that I changed the way the Author Contact information and tag is laid out. I took advantage of a WordPress built-in feature that hides the email address from bots and harvesters that steal email addresses for spam. If I was using the email tag within the Loop, it would be <a href="mailto:<?php echo antispambot(get_the_author_email()); ?>">Email Author</a>. Just for your information.

From there, the Author Template File goes on as usual, and the WordPress Loop begins, gathering information about the posts written by the author. It is not necessary to change the following in your author.php template file. This is just an example of how I laid out my author search results:

<?php while (have_posts()) : the_post(); ?>
<div class="post">
<h2 id="post-<?php the_ID(); ?>" class="posttitle"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div id="searchinfo">By: <?php the_author_posts_link('namefl'); ?> | Categories: <?php the_category(', '); ?> | Comments: <a href="<?php the_permalink() ?>#comments" title="<?php the_title(); ?>" rel="bookmark"><?php comments_number('0','1','%','%'); ?></a></div><!-- end searchinfo -->
<div class="entry"><?php the_excerpt(); ?> <div class="readmore"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">CONTINUE READING</a></div>
</div><!-- end of entry -->...

The end results of my custom author.php template file for the section with the author details looks like this.

WordPress Customized Author Template File by Lorelle VanFossen

Thanks to the great folks who volunteer their amazing talents on the WordPress Codex for helping me figure this out!

For more WordPress Plugins and techniques for customizing author pages and the author template file, see WordPress Plugins for Multiple Blogger Blogs.

Related Articles

Site Search Tags: , , , , , , , , ,

Feed on Lorelle on WordPress Subscribe Feedburner iconVia Feedburner Subscribe by Email
Copyright Lorelle VanFossen, the author of Blogging Tips, What Bloggers Won't Tell You About Blogging.


  1. Posted May 7, 2006 at 8:31 pm | Permalink

    Thanks for the step-by-step explanation. I’m thinking that the concept here could be applied to create other specialized pages by switching out the tags.–Dan

  2. Posted May 7, 2006 at 9:25 pm | Permalink

    Nice article, thanks.

  3. Posted May 30, 2006 at 6:43 pm | Permalink

    Those of us who would rather not tinker with PHP will wait for a plugin or widget.

  4. Posted February 27, 2007 at 11:27 am | Permalink

    I want to show up the authors with no posts (yet). Can u help ?

  5. Posted February 27, 2007 at 11:43 am | Permalink

    Empty Authors and Categories will not appear by default on a WordPress blog. If you need to know the number of posts for specific authors within your Administration Panels, check out one of the different statistics in Counting WordPress: Statistics WordPress Plugins for author statistics.

    Other than that, the best place to look for a custom script or request one would be in the WordPress Support Forum.

  6. johan
    Posted May 10, 2007 at 5:06 pm | Permalink

    Do you know how to get the Userextra and/or Usermeta plugins to work for the author.php page.
    I’ll filles in the adres value and want to print Extended User Data which is profided using the plugin:

  7. Posted May 10, 2007 at 8:34 pm | Permalink

    If you want the Plugins to work in the author.php, you have to put the Plugin template tags into the template file, author.php. Follow the instructions EXACTLY as put in the readme.txt or on the Plugin author’s website and that will allow you to add the meta information.

    If you need more help with the Plugins, please contact the Plugin author directly.

  8. Posted June 16, 2007 at 10:54 pm | Permalink

    thanks so much for this, it REALLY helped me out a lot on my author pages!

  9. Posted March 3, 2008 at 2:52 pm | Permalink

    Great Article! But how do I get the author image onto the author page?

  10. Posted March 3, 2008 at 3:30 pm | Permalink

    There are WordPress Plugins to create variables which include photographs of the authors onto the author.php template file. See WordPress Plugins for Multiple Blogger Blogs for examples.

  11. Posted August 27, 2008 at 1:14 am | Permalink

    I had the same problem actually. I used the Loop to display ONLY author information (no posts), but it would duplicate. If the author had posted 3 posts, the author information would be displayed 3 times. I had to get the information out of the Loop. Thanks for the tips.

  12. Posted October 2, 2008 at 12:06 am | Permalink

    Need to connect to a Database outside of wordpress.
    Is this possible and if possible how do one do it.

  13. Posted October 29, 2008 at 6:14 pm | Permalink

    So where is an example of this in action … when I click on any link that goes to your author page, all I see is a list of your posts, not your custom stuff …

  14. Posted October 29, 2008 at 8:34 pm | Permalink

    @ @Babiesonline:

    I can’t do things like this on my blog. You can see this at Taking Your Camera on the Road, though it is currently in flux so pardon my dust if things aren’t working quite right. 😀

    I also have examples of this in my genealogy blog.

  15. Posted October 30, 2008 at 10:17 pm | Permalink

    Have you ever been able to add a picture of the author? How about other fields like hobbies, more than one site, links to other sites they want to showcase?

  16. Posted October 31, 2008 at 11:39 am | Permalink

    @ Jamie Birch:

    Adding a picture to the author page and elsewhere is easy. Check out the article details and links within and these WordPress Plugins: WordPress Plugins for Multiple Blogger Blogs.

  17. Posted November 8, 2008 at 7:25 pm | Permalink

    Great post Lorelle! I’m building a custom author.php for my WordPress blog using snippets from your post and I’m having troubles with listing an author’s posts! The tag the_permalink() is throwing up strange outputs! Have a look at them at

  18. Hedley
    Posted January 9, 2009 at 8:32 pm | Permalink

    Any idea if you can test, within the `user_url; ?>` statement, for the presence of a URL on the user record, and if one does not exist suppress the display of the default “http://”?


  19. Posted January 11, 2009 at 4:42 am | Permalink


    you can do something like this:

    user_url) {
    echo $curauth->user_url
    } else {
    // Do nothing

    Nice trick, Lorelle!

  20. Posted January 11, 2009 at 4:46 am | Permalink

    Well, that didn’t work… Lets try it without the php tags…

    if (!empty($curauth->user_url)) { echo $curauth->user_url; } else { }

  21. Posted February 15, 2009 at 1:51 pm | Permalink

    Hi there! nice post, very useful!

    I have an uncommon request.. I’d need to list authors depending on the period they wrote..
    for istance I have authors that wrote only on march 2008 and never again.. how could I list them?



    • Posted February 15, 2009 at 3:28 pm | Permalink

      Your request is actually quite common, and the answer is “it depends.” It depends upon how you highlight authors, what your agreement and arrangements for allowing the contributors to work on your site, and how valuable it is to you to highlight their names. If they are top notch, recognizable names, then no one cares when they wrote the content, it’s the names that matter, so leave them in the list.

      If you did not specify any agreement for inclusion on the list, then take them out by finding a Plugin (or writing one) that works with the wp_list_authors template tag to exclude author IDs. Not familiar with one, but you might be able to find such a Plugin. Or create a manual author list that links to the author pages of posts.

      To list authors by time period of their contribution, then create a manual list with the names and dates in the link.

      Otherwise, how important is it to highlight the authors in a list? Why not let their bylines link to their author pages and skip the list. Those seeking posts only by a specific author will click on the author byline link to find all the posts they’ve written.

  22. Posted February 15, 2009 at 5:02 pm | Permalink said mostly right..
    but in this particular case I will have on my blog 7 writer that will change each u may imagine that I might need to classify them depending on the period they wrote..anyway I’ll figure it out..

    I guess should be something dealing with a particula while-have-post condition that satisfy the dates I need and then show just author link instead that post excertp or other post stuff.

    thank u anyway 😉


    • Posted February 15, 2009 at 8:43 pm | Permalink

      No, there isn’t a conditional script I can think of that would check dates and such. Do check the WordPress Support Forums for more help. I’m sure someone might have a better suggestion.

      I still recommend that you skip the list of authors and simply have every byline link to the author.php template file to display posts by that author. The byline credit is usually more important than being on a list for a month or less. Are you sure your readers care “when” someone wrote something or care more about what they wrote not who wrote it?

  23. Posted June 21, 2009 at 11:05 pm | Permalink

    This post has helped me out so many times, Thanks for writing it! 🙂

  24. Drew
    Posted November 20, 2010 at 10:48 pm | Permalink

    Lorelle: Thank You!

    I tried and tried to pull the_author_meta and it finally dawned on me that I was outside the loop. Durrr. So, thanks for another very helpful post here, saved me a lot of additional frustration.

  25. Posted November 30, 2010 at 7:33 pm | Permalink

    GREAT post! Thanks for this information, it was just what I needed for another couple of sites I’m working on. Really appreciate that you put it out there for all to see!

  26. Posted March 1, 2012 at 4:43 am | Permalink

    Thank you Thank you Thank you
    I had the same issue. Display some author’s data OUTSIDE the loop.

15 Trackbacks/Pingbacks

  1. […] […]

  2. […] I love challenges and recently I was challenged with a way to make information about a post author show up in a WordPress Theme outside of the WordPress Loop, which I explained in “Using Author Template Tags Outside of the WordPress Loop”. Another even challenging author issue came up with my genealogy blog. How to add dead authors to my blog authors and users. I uncovered the mysteries in “Blog Contributors – Wanted Dead or Alive”, and had some morbid fun while I was at it. In the future, I will use this information to create more customized author pages, so stay tuned for more on this. […]

  3. […] Using Author Template Tags Outside of the WordPress Loop by Lorelle […]

  4. […] Lorelle on wordpress […]

  5. […] Using Author Template Tags Outside of the WordPress Loop […]

  6. […] Using Author Template Tags Outside of the WordPress Loop […]

  7. […] Using Author Template Tags Outside of the WordPress Loop […]

  8. […] – I finally managed to get my head around using WordPress template tags outside The Loop (thanks to this blog post), meaning that I could get a nice, personalised page for each author’s archive. Other neato […]

  9. […] Using Author Template Tags Outside of the WordPress Loop […]

  10. […] Using Author Template Tags Outside of the WordPress Loop « Lorelle on WordPress […]

  11. […] Using Author Template Tags Outside of the WordPress Loop […]

  12. […] Using Author Template Tags Outside of the WordPress Loop […]

  13. […] Using Author Template Tags Outside of the WordPress Loop […]

  14. […] Using Author Template Tags Outside of the WordPress Loop […]

  15. […] Using Author Template Tags Outside of the WordPress Loop […]

Post a Comment

Required fields are marked *

%d bloggers like this: