WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Force template to show post author's nickname (5 posts)

  1. chrisbfinternet
    Member
    Posted 4 years ago #

    Hi there,

    I'd like my template to always retrieve the authors nickname, and never their username, regardless of what is set in the users profile.

    I did give the following a try, but I couldn't make it work:

    single.php
    <?php
    if(isset($_GET['author_name'])) :
    $curauth = get_userdatabylogin($author_name);
    else :
    $curauth = get_userdata(intval($author));
    endif;
    ?>

    Post by: <?php echo $curauth->nickname;?>

    Can anyone make a suggestion, or post some tips?
    Thanks,
    Chris

  2. MichaelH
    Member
    Posted 4 years ago #

    The Author_Templates article has an example:

    <p>This is <?php echo $curauth->nickname; ?>'s page</p>
  3. chrisbfinternet
    Member
    Posted 4 years ago #

    Hi MichaelH,

    Thanks for taking the time to reply, but that's just what I posted that isn't working :(

    Thanks,
    Chris

  4. MichaelH
    Member
    Posted 4 years ago #

    Sorry...missed that...what about:

    <?php the_author_meta( 'nickname', $userID ); ?>

    Template_Tags/the_author_meta

  5. chrisbfinternet
    Member
    Posted 4 years ago #

    Wicked! Thank you! :)

Topic Closed

This topic has been closed to new replies.

About this Topic