Adding avatars on a Digg 3-column theme for Wordpress

One of the problems moving out of Wordpress.com is that the theme that you’re accustomed too somehow won’t work as expected. The Digg 3-column theme is an old theme so not all the features of the latest Wordpress release works on it.

One of which is the support for Avatars/Gravatars. Wordpress 2.5 and up incorporates avatars on comments without the need of plugins (Settings > Discussion).

But with the Digg 3-column theme, you need to tweak the code a little. Don’t worry, it’s not that hard.

1. First go to your themes folder for Digg and open comments.php for editing.

2. Then look for this piece of code:

<!– You can start editing here. –>

<?php if ($comments) : ?>
<h3 id=”comments”><?php comments_number(’No Responses’, ‘One Response’, ‘% Responses’ );?> to &#8220;<?php the_title(); ?>&#8221;</h3>

<ol class=”commentlist”>
<?php foreach ($comments as $comment) : ?>

<li class=”<?php echo $oddcomment; ?>” id=”comment-<?php comment_ID() ?>”>

<div class=”commentmetadata”>

3. Add the following code directly under it.

<?php if(function_exists(’get_avatar’)) { echo get_avatar($comment, ‘35′); } ?>

The number on the right is the size of your avatar. In this case, it’s 35 x 35. Feel free to change it. This is the code that needs to be placed on all old themes to support avatars.

4. Save it afterwards then open style.css

5. Insert this piece of code to style your avatar somewhere,

.post img.avatar {float:right; margin-left:5px; padding:0px;}

This code positions the avatar on the right of the comments just like what it does on Wordpress.com.

6. Save your file and view your work.

That should do it. Let me know if you’re having any problems.


You might also be interested in:

Leave a Reply

Theme: Digg 3 Column by WP Designer customized by Calvin