WordPress Tip – Identicons and MonsterIds without a plugin

Okay, no one wants to trumpet new-found knowledge as much as a newbie. So here I am, telling all of you about the easy way I found to add identicons (and MonsterIds and Wavatars) without a plugin. This tip only applies to people who are using WordPress version 2.5 and above.

It kept bothering me that all my commenters who didn’t have a Gravatar (which is most of you guys) had to make do with the “Mystery Man” blank image. I tried correcting this by using the WordPress-Gravatar plugin, but that didn’t help. The plugin was overly enthusiastic and proceeded to dole out two identicons per comment – one replacing the “mystery man” and a smaller one beside the commenter’s name.

But after a lot of searching online, I finally found this really quick fix – you just have to tweak the comment.php file for your current theme a very little bit. (You will find the file under Design –>Theme Editor–>Theme Files.

First, copy-paste and save the comment.php file as a text file in your PC. You will need this if you ever have to undo the changes.

Next, search for the get_avatar call. Specifically, you will see a line that looks something like this:

echo get_avatar(get_comment_author_email(), ‘45′) ;?>

Don’t panic if the parameters are not exactly the same, it doesn’t matter. There is only one place in your comment.php file that the words “echo get_avatar” appear, so there is no way you can go wrong.

All you need to do is change this to

echo get_avatar(get_comment_author_email(), ‘45′,’identicon’) ;?>

In other words, just add the word “identicon” at the end and you are done.

If you want MonsterIDs instead, change it to

echo get_avatar(get_comment_author_email(), ‘45′,’monsterid’) ;?>

For Wavatars,

echo get_avatar(get_comment_author_email(), ‘45′,’wavatar’) ;?>

That’s it really.

Plus of course, the ‘45′ is just the avatar’s pixel size, so while you are at it, you can change that too..

I had a hard time finding this info online. I kept experimenting with all sorts of plugins, none of which are really needed. So for anyone who is in the same situation as me, I hope this tip helps!

Ciao, now that I have done my good deed of the day, I am off for a long weekend :)

Popularity: 9% [?]

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • FriendFeed
  • IndianPad
  • Netvibes
  • NewsVine
  • StumbleUpon
  • Twitter