I'm using WordPress with bbPress and Gravatar for user avatars. I want to display the user's avatar next to their topic. I'm using:

echo get_avatar( get_the_author_meta( 'ID' ), 32 );

Which get's me this:

enter image description here

I know that my author image is set because I set it myself.

  • Are you working with bbPress or something? If so, you should update your question to be more specific.
    – Jami Gibbs
    Dec 26, 2016 at 13:15

1 Answer 1


The get_avatar function is a pluggable function with it's first parameter being either the user's ID or email.

You're using get_avatar with get_the_author_meta('ID') which should give you the ID of the current user within the Loop.

From the Codex

If used within The Loop, the user ID need not be specified, it defaults to current post author. A user ID must be specified if used outside The Loop.

get_the_author_meta( string $field = '', int $user_id = false )

So it would be redundant using get_avatar with get_the_author_meta('ID'), you can just specify the ID directly:

echo get_avatar( USER_ID, 32 );
  • thank you Tunji , it kinda fixed the problem but still ,it shows the default avatar picture for all users Dec 26, 2016 at 15:42
  • You have to make sure you're passing the right user_id for each user
    – Tunji
    Dec 26, 2016 at 15:49
  • @ouqasmohamed I'm wondering if you should be using bbpress specific functions here: get_avatar( bbp_get_topic_author_id( $topic_id ), $size )
    – Jami Gibbs
    Dec 26, 2016 at 15:56
  • @ouqasmohamed Or even better: bbp_get_topic_author_avatar bproots.bbroots.com/reference/functions/…
    – Jami Gibbs
    Dec 26, 2016 at 15:58
  • @jami0821 now with bbp_get_topic_author_avatar() , i get in result the post_id not the avatar, here is the code i'm using inside the loop bbp_get_topic_author_avatar ( bbp_topic_id() , 40 ); Dec 26, 2016 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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