Support » Fixing WordPress » Author's name on archive page

  • Resolved steve2010


    Is there a way to change the header of the “author archive” page without creating an author archive template, perhaps just by modifying the archives template php? I’d like to add the author’s name since this is a multi-author site.

Viewing 8 replies - 1 through 8 (of 8 total)
  • forunner


    Yes the codex is great i agree, but unfortunately it does not answer the question being asked.

    Steve, you’ll need to work out which file currently displays the unwanted heading and add an additional conditional statement..

    For example let’s say you have a few lines like this (example only, obviously yours will differ)..

    <?php if( is_archive() ) : ?>
       <!-- archive heading HTML -->
    <?php elseif( is_category() ) : ?>
       <!-- category heading HTML  -->
    ... and so on..

    You’d then just add another condition like so..

    <?php if( is_archive() ) : ?>
       <!-- archive heading HTML -->
    <?php elseif( is_category() ) : ?>
       <!-- category heading HTML -->
    <?php elseif( is_author() ) : ?>
       <!-- your new author heading HTML here  -->

    If that’s a little too much for you to follow, post the code from the file that currently deals with the heading and i’ll help you do it… 😉

    If posting code, please use a pastebin… 🙂



    Hi Mark,

    Thanks for the reply.

    The code is at

    (or should I send it to you in another format?)

    What I’d like to do is change the header on the author archive page. Now it reads “Author Archive.” I’d like it to read something like “Archive for [author’s name]”. Thanks for the help.

    Is the author name shown in the URL when displaying an author page on your site?

    If so, try updating this line..

    <h2 class="pagetitle">Author Archive</h2>


    <h2 class="pagetitle">Archive for <?php echo get_query_var('author_name'); ?></h2>

    If not, i’ll have to come up with something else for you.. 🙂



    No, unfortunately, the URL for the author archive page just ends with the number ID for the user, e.g., /?author=2. (I could try getting the author name into the URL using permalink, but I’m not sure how to structure the permalink so it works the way you’ve set this up.) Thanks for following up on this.

    Ok, switch that for..

    if(get_query_var('author_name')) :
        $curauth = get_user_by('slug', get_query_var('author_name'));
    else :
        $curauth = get_userdata(get_query_var('author'));
    <h2 class="pagetitle">Archive for <?php echo $curauth->nickname; ?></h2>

    Will support both author name and author id queries.

    As seen in the example on the author template codex page.

    Hope that helps.. 😉




    That worked perfectly. Very impressive. Thanks a bunch, really.


    You’re welcome.. 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Author's name on archive page’ is closed to new replies.