K2 Quickie: Link Gravatars to Comment Author’s URL
Wouldn’t it be nice if the gravatars on your K2 and WordPress-powered blog actually linked to the author’s website instead of gravatar. For those out of the loop, gravatars are globally recognized avatars. Once a person has registered their email address with gravatar.com and paired it with an avatar, they can go around commenting on gravatar-enabled blogs (most blogs are these days) and have their unique avatar appear adjacent to their insightful comment.
By default K2 links each gravatar, regardless of comment author, to the gravatar website. While this does help promote awareness about gravatars and spread the word, it’s not exactly helpful for those wishing to access that commenter’s site. Luckily this can easily be changed and add that extra bit of usability to your blog.
Fire up your FTP application and navigate to your K2 directory. Open up comments.php in your favorite text editor, whatever it may be.
Look for this snippet (around line 60):
and replace it with this chunk:
In the last bit of code, I made use of two WordPress tags; comment_author_url and comment_author. The first outputs the commenter’s url while the second tag outputs the commenter’s name, as expected.


Thanks Paul, I implemented this on my site :).
Sweet, thanks for the tip !
That’s great Paul! Thanks. I’ve been thinking about how to do something like this for a few weeks now but never got around to trying it, you saved me a bit of work.
oh gosh, awesome tip!
Nice tip Paul :)
will implement it in my blog soon.
Haha this is funny. Last month I suggest to Mike and Chris about removing the gravatar.com URL.
Great stuff as usual Paul!
Thanks, a great idea. Seems so obvious now though.. :)
I’ve tweaked the code a little so my gravatars are only linked when the commenter leaves an URL. The code is available on my blog.
The code for this section has changed in the upgrade to WP 2.5
It might be useful to have another chuck for us that upgraded! ;)