• Anyone know how to do this?

    This is what I have:

    <div class="gravatar">
    <?php echo get_avatar( get_the_author_id(), $size = '96', $default = '<path_to_url>' ); ?>
    <br />
    <?php the_author_posts_link(); ?>
    </div>

    But that just displays the authors name under the Gravatar, linked to the author’s page.

    I need to do this: <a href="url to author's page"><?php echo get_avatar( get_the_author_id(), $size = '96', $default = '<path_to_url>' ); ?></a>

    Anyone know how?

    I tried: <a href="<?php echo $curauth->user_url; ?>"><?php echo get_avatar( get_the_author_id(), $size = '96', $default = '<path_to_url>' ); ?></a>
    but it didn’t work (and yes, I have the variable $curauth before the loop, and it’s correct and functioning).

    Thanks in advance!

Viewing 2 replies - 16 through 17 (of 17 total)
  • Well, I gave it a whirl and I couldn’t get it to work. Here’s my code:
    In functions.php

    function get_the_avatars_with_link_to_authors(){
    	$authors = get_users_of_blog();
    		foreach ($authors as $author){
    			$author_data = get_userdata($author->user_id);
    			$author_nicename = $author_data->user_nicename;
    			$author_displayname = $author_data->display_name;
    			$link .= '<li style="list-style-type:none;list-style-position: outside"><a style="text-decoration:none;" href="' . get_author_posts_url($author_data->ID) . '" title="' . sprintf( __( "View %s's profile" ), $author_displayname ) . '">' . get_avatar($author_data->ID,$size = '35') . $author_displayname . '</a></li>';
    		}
    	return $link;
    }

    and in my sidebar I have:

    <?php printf( __( '%s', 'libra' ), get_the_avatars_with_link_to_authors() ) ?>

    The solution from cais is great however: get_the_author_id() is deprecated as of 2.8.

    For WordPress 2.8, please use get_the_author_meta(‘user_email’).

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘How to make Gravatar image a link to author’s page?’ is closed to new replies.