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 🙂

Advertisements

7 thoughts on “WordPress Tip – Identicons and MonsterIds without a plugin

  1. As a computer science student, it is nice to read something explained in such simple layman’s terms. 😀 @ There is only one place in your comment.php file that the words ?echo get_avatar? appear

    🙂

  2. Adithya: Thanks, I wish more people would explain stuff in simple terms, don’t you? Too many software professionals seem to write manuals assuming that everyone is as familiar with coding as they are 😦

  3. Thanks for posting this – I’d figured it was something in the theme overriding the WordPress setting, but wouldn’t have known what to change. Identicons are working fine now.

    Lekhni: You are welcome! Glad to have been of help. I can understand how frustrating it must have been.

  4. That was SUPER useful! The current version of the “multi-color” theme doesn’t support identicon by default, I had to modify the function comments_callback from functions.php in the same way you say.

    THANKS!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s