Tips and Advice For Your Web Site
Ever wished your blog’s comments could show Twitter avatars? By default, WordPress will show a user’s Gravatar. But with the increasing popularity of Twitter, it may make more sense to show your commenters’ Twitter pics! This cool plugin allows you to use both Twitter and Gravatar; it takes the commenter’s email address and if they have a Twitter account it displays their avatar. If they do not have a Twitter account, it next checks to see if they have a Gravatar. The end result is having more photos in your comment section.
To install the plugin, you first need to download it here. Once you have downloaded it, you can upload it to your WordPress under the Plugins section. Next you’ll need to modify the comments.php file (don’t worry, it sounds much harder than it is).
Click on the Editor link under the Appearance category in your WordPress dashboard. Click on the comments.php file (or whatever file manages the comments of you blog). Most comments sections already support gravatars, so locate the line of code that mentions gravatars and replace it with the following:
<?php twittar(size, placeholderimg, border, class, usegravatar, rating); ?>
If you don’t have any code mentioning gravatars, then you don’t need to replace anything – just insert the line of code above. Next, you must change the values inside twittar(); by replacing the words with values. Here’s how:
size
The size of the avatar (in pixels). Just replace the word “size” with the number (e.g. 45), without “px.” It is the size for both width and height.
placeholderimg
The URL for the image you want to use when the user has neither a Twitter account nor a gravatar. Must be inside quotes (””). Optional.
border
The color for the 2px border. Insert the hexadecimal code of the color (e.g. “#FFFFFF” with the “” marks) but only if you want to use one.
class
A CSS class that you want to use to style the avatar. For example: “myimg.” In the CSS, you would include .myimg { }. Put inside “”.
usegravatar
Just insert 1 if you want to use gravatars, and 0 if you don’t. If you choose to use gravatars, it will try to load a gravatar image if a Twitter account and picture is not found, otherwise it will load the placeholderimg (default) image directly.
rating
Parameter for gravatars only.
Keep in mind that if you don’t want to specify one of the values above, like placeholderimg, you can just replace the text with “”. Make sure you save your changes to the comments.php file when you’re done! Let me know if you run in to any issues with the install. I’ll be happy to help!
Starting a web site or trying to improve your online presence can be a daunting task for the casual computer user. Drawing from experience in the web hosting and ecommerce industry, The Common Hoster is your spot for technical resources, in an easy to understand format!
1 Response to Displaying Twitter Avatars In Your Blog Comments
uberVU - social comments
December 2nd, 2009 at 5:02 pm
Social comments and analytics for this post…
This post was mentioned on Twitter by TheCommonHoster: Check out my new blog post – Displaying #Twitter Avatars In Your #Blog’s Comments http://bit.ly/4IE1Ph...