Amber Weinberg: Freelance Web Developer specializing in semantic WordPress, Mobile, CSS and HTML5 Development

The Blog

WordPress Gravatars: Changing Sizes & Adding Author Photos

Posted on 12/10/09 in blog, development about , ,

Lately, I’ve come across multiple instances of needing to do something different with the default Gravatars on WordPress.  There isn’t a lot of documentation out there and it took me a while to figure out how to do some of these, so I thought I’d make it easy for you by showing you how to change the default size of a gravatar in WordPress 2.8+ and how to add a neat author avatar and link.

Changing the size of your comments Gravatars in WordPress 2.8+

For some reason, it was much easier to change Gravatar size before WordPress 2.8. There’s plenty of documentation on how to do that, but we”ll focus on the later version only. Changing the actual size of the gravatar is easy, it was just a PIA to figure out where and how to do it.

1. Open up your comments.php file under wp-content/themes/YOUR THEME and locate

<?php wp_list_comments();?>

It should be around line 24, depending on your theme. This calls the list of comments and is where you need to tell it to change avatar size. Replace it with:

<?php wp_list_comments('avatar_size=80');?>

This makes an avatar of 80×80 pixels large. You can change the 80 to any size you want it to be.

Adding an Author Photo, Link and Name.

By default, WordPress comes with an author section in the meta tag, but it’s commented out. If you want to show the author of the post, you can uncomment it out. You can find this code in both index.php and single.php of the regular WordPress theme. It looks like:

By: <?php the_author() ?>

Now all this does is add the name of the author, like:

By: Amber

If you wanted to add the Gravatar associated with the author, you would add:

<?php echo get_avatar( get_the_author_email(), '36' ); ?> By: <?php the_author() ?>

This calls the avatar using the author’s email. Change the size of the avatar itself by changing the number. This adds the gravatar next to the By: Author.

If you want to add the author’s link that they specify in their profile. Simply add:

<?php echo get_avatar( get_the_author_email(), '36' ); ?> By <a href="<?php the_author_link() ?>"><?php the_author() ?></a>

This links the author’s name. It looks like:

CloudManic_1260467636527

This can be modified to show an author’s information and bio, like you see at the bottom of FreelanceFolder and FreelanceSwitch articles. While I don’t see the point of doing one on a one person blog, like mine, it’s great if you’re a larger blog with multiple authors.  There is a lot more you can add to the author section such as their bio, links and contact information.

Check out WordPress’s author meta section for more that you can do with this.

About the author
Amber Weinberg specializes in clean and semantic XHTML, CSS and WordPress development. She has over 10 years of coding experience and is pretty cool to work with. Amber is available for freelance work, so why not hire her for your next project?

3 Awesome Comments

  1. Lalit says:

    Thanks for the information Amber. can you tell me how to replace default Gravatar image with some other image?

Leave a Reply