One of the reasons why I haven’t been paying much attention to this blog is the fact that I have started several new meant-to-monetize blogs over the past couple of months. Being very particular about my blog themes, I have been tweaking themes here and there while referring to the WordPress Codex for the template tags.
An issue I was trying to solve within this past hour was my Gravatars setting. I would like to display Gravatars only on normal comments left by visitors. I thought it makes no sense at all to display them on pingbacks, when all you get are those mystery man icons.
You’re suppose to add the following code to enable Gravatar support on WordPress comments:
<?php echo get_avatar( $comment, 32 ); ?>
The code by itself doesn’t solve my dilemma. In other words, that code will display Gravatars on all of my comments, regardless of whether they are normal comments, pingbacks, or trackbacks.
The following simple hack, though, does exactly what I wanted:
<?php if($comment->comment_type=='') { echo get_avatar( $comment, 32 ); } ?>
Surprisingly, I couldn’t find any online documentation concerning disabling Gravatars on pingbacks, so I had to look through some of my very own customized themes as well as a little reference to my WP database to understand how I can go about solving it.
Sweet, eh? Try it yourself. WP theme developers may find this code handy.
Check out my other posts: « Kiva.org — giving and doing business all in one / FaceBook’s urTurn Scam? »
Thank you once again for an amazing WordPress solution. You rock.
Well, I havent heard that before. I think it is very useful, thanks…
Waiting for it to launch the new product. I wanted to know what are the new features available on it.
thanks for that code. i believe that really a big help.
Hi there, thanks for this! I’m new to WordPress, although I do create websites in old fashioned html. I appreciate your posting of this code, but am newbie enough that I don’t know where it gets added/changed. Would appreciate your guidance!