Ads 468x60px

Bollywood news

Pages

Sunday, January 9, 2011

How to Change Avatar Size in WordPress Comments

tweet 
Facebook share

I wanted to increase avatar size (Gravatar) in my WordPress comments, but any amount of CSS tweaking for the avatar size would not work. I realized the avatar size was generated hard coded in html and there was no way to change that.

A quick view at your comments.php file would reveal that the comments are output by this code.

<ol class="commentlist">
<?php wp_list_comments(); ?>
</ol>

Note that we had set the type argument to show comments only (not pingbacks / trackbacks) so our code looks like this right now

<ol class="commentlist">
<?php wp_list_comments(array('type' => 'comment')); ?>
</ol>

So wp_list_comments is the target file which generates the hard coded avatar size of 32x32px. I wanted to increase the avatar size to 48x48px, so here is how I modified the code to look like this. Change the 48 to any size you like from 1-512.

<ol class="commentlist">
<?php wp_list_comments(array('avatar_size' => '48', 'type' => 'comment')); ?>
</ol>

Now we are showing comments with avatar size of 48x48px. Post a comment and try for yourself. (Obviously you have a gravatar by now with the same email address or your avatar would not show on any site).

Original article: How to Change Avatar Size in WordPress Comments
Copyright 2010. Quick Online Tips. All Rights Reserved.

0 comments:

Post a Comment