Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Display Twitter Avatars in WordPress Comments

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Display Twitter Avatars in WordPress Comments

As you know that WordPress has an option to display gravatars in the comment for your users. Well sometimes users don’t have a gravatar account, but they have a twitter account. In this article we will share a way for you to combine gravatar and twitter avatars to display in your comment area.

Twitter Avatars in WordPress Comments

What does this plugin do?

  • Loads user’s avatar by matching the email address to the user’s Twitter email address.
  • If user doesn’t have a Twitter account, it first tries to load user’s gravatar. If user doesn’t have a gravatar, it loads a default image. This is an optional setting.
  • You can set a 2-pixel border to the images (you choose the color).
  • You can choose the sizes: Preferred ones are 24, 48 or 72 pixels.
  • You can set an image other than the default one to load if a user doesn’t have a Twitter account or a gravatar.
  • It builds a valid image for you (with alt and title attributes, etc.) based on user details.
  • Allows you to add a class to the image, so you can style it later.

Installation Guide

First download and activate the plugin. Then you would need to place this code in your comment(s).php where you want to display the avatar.

<?php twittar(size, placeholderimg, border, class, usegravatar, rating); ?>

Now you would need to change the parameter in the code using the guide below:

The size of the avatar (in pixels). Just insert the number (e.g. 45), without “px.” It is the size for both width and height.

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.


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.

A CSS class that you want to use to style the avatar. For example: “myimg.” In the CSS, you would include .myimg { }. Put inside “”.

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.

Parameter for gravatars only.

Note: if you want to skip a parameter and add another in front of it, just replace it with “”.

For Example:

<?php twittar("45", "", "", "myimg", 1, "R"); ?>

License: The plug-in is released under the GPL. You can use it for all your projects for free and without any restrictions. You may modify the plug-in as you wish.

Download the Plugin

Source: Smashing Magazine

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Dylan Lopez says:

    i love to microblog that is why i am very addicted to Twit my daily activities.;.

  2. BrevilleJE900 says:

    Cool plugin. Would be nice to see in in action here on the site.

  3. Max says:

    thanks for sharing))
    very useful plugin

  4. Erica M says:

    Am I doing something wrong? I’m getting a forbidden 403 error when clicking the download link!

    • Editorial Staff says:

      No you are not doing anything wrong. Smashing magazine has limited access on all download links from external site. Please go to the source link on this page right below the download link. Download the plugin from there.

  5. Rick says:

    Very useful plugin. Many more people have Twitter accounts than gravatars, in my experience.

  6. Husien Adel says:

    nice plugin :)
    thanks for sharing

  7. Prajwal Rao says:

    Fantastic Plugin.. Thanks a ton for this.. Implementing now.. :)

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.