On my website I would enjoy to make it so that if a reader clicks an author or user's name it takes them to a page displaying their profile picture and bio. All users on my blog have the option to add a profile picture or bio before signing up. How could I make it so that it displays the information they submit when their username is clicked? I think to do this you have to edit the author.php file but I'm not sure where to go from there. Any help is greatly appreciated thanks.

BTW - I am currently trying to learn PHP so hopefully soon I won't be asking questions like this.


You will need something like this in your author.php file. Taken from the Codex. http://codex.wordpress.org/Author_Templates

<?php get_header(); ?>

<div id="content" class="narrowcolumn">

<!-- This sets the $curauth variable -->

$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));

<h2>About: <?php echo $curauth->nickname; ?></h2>
    <dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd>
    <dd><?php echo $curauth->user_description; ?></dd>

<h2>Posts by <?php echo $curauth->nickname; ?>:</h2>

<!-- The Loop -->

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <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('&');?>

<?php endwhile; else: ?>
    <p><?php _e('No posts by this author.'); ?></p>

<?php endif; ?>

<!-- End Loop -->


To get the profile photo you need to use the get_avatar function and use the users email as a parameter.

<?php echo get_avatar( $curauth->user_email ); ?>

More information on get_avatar here: http://codex.wordpress.org/Function_Reference/get_avatar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.