WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I fetch anyone’s gravatar image?

I need to show users gravatar image on a custom profile page that am making.

I have so far integrated the option of Facebook Profile Pic (which automatically gets grabbed) and also am allowing user to assign his/her own photo (on wish).

What I need to do is, if person do not comes from FB, then maybe his email or something should be used to see if he/she has a gravatar, if yes then display it. How can I do that?


share|improve this question

You can use get_avatar. The following example prints an avatar in 96 px, assuming that you have the user id stored in $user_id, and prints a fallback user.png if no such user or image could be found.

echo get_avatar($user_id, 96, get_stylesheet_directory_uri() . '/images/user.png');
share|improve this answer
i will implement it asap, and will revert back. thanks for the reply. – vajrasar Feb 16 '13 at 10:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.