Grow your CSS skills. Land your dream job.

Last updated on:

Display a User Gravatar from an Email Address

  $gravatar_link = '' . md5($comment_author_email) . '?s=32';
   echo '<img src="' . $gravatar_link . '" />';

The variable "$comment_author_email" would be a string of a valid email address. If the email isn't in the Gravatar database, it will return a default graphic. "$comment_author_email" is the default WordPress variable that populates from a cookie for people who have previously commented (if the theme supports it).


  1. Tymon Sturgeon

    Thanks! This is exactly what I was looking for!

  2. Thanks a million, I noticed that WordPress had the ability to show Avatars, But i couldn’t for the life of me work out how to add them. Saw this post, and thought I would give it a go. :)

    Also, this should post my gravatar i presume?

  3. Permalink to comment#

    Cool :D One module goes trash bin :)


  4. Dawood
    Permalink to comment#

    Great !!!

Leave a Comment

Posting Code

Markdown is supported in the comment area, so you can write inline code in backticks like `this` or multiline blocks of code in in triple backtick fences like this:

<div>Example code</div>

You don't need to escape code in backticks, Markdown does that for you. If anything screws up, contact us and we can fix it up for you.

*May or may not contain any actual "CSS" or "Tricks".