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

I have a php widget, and I need to show the avatar of the current logged in user, and I'm calling this code: <?php echo get_avatar(); ?> But its only outputting the default avatar.

Is there a global I need to add above it?

share|improve this question

This should work great... in this example i am using wordpress codex so you can comapre:

From Wordpress Codex

<?php echo get_avatar( $id_or_email, $size, $default, $alt ); ?> 

so... Based on that...

This is the code you should embed in the desired location in your theme:

    $size = array(60,60); // this is the size of the avatar
    echo get_avatar( $current_user->user_email, $size, $default, $current_user->display_name );

Hope this helps :)

share|improve this answer
Doesn't seem to change anything. – Jack Stewart Nov 5 '11 at 3:50
it should work mate.. are you sure you are logged in? hmm.. try to enter this after wp_get_current_user(); --THIS--> echo 'User email: ' . $current_user->user_email . '<br />'; – Sagive SEO Nov 5 '11 at 4:00
nope. not working – Jack Stewart Nov 5 '11 at 4:37
Noting echoes? not even the plain text meaning 'User email:' i guess your not pasting that code in a place that would result in the apearnce of the thumb niether the text i gave you in order to check... – Sagive SEO Nov 5 '11 at 5:19

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.