admin管理员组

文章数量:1313121

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:

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

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:

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

Share Improve this question edited Dec 26, 2016 at 16:47 Jami Gibbs 7694 silver badges13 bronze badges asked Dec 26, 2016 at 12:37 ouqas mohamedouqas mohamed 11 silver badge8 bronze badges 1
  • Are you working with bbPress or something? If so, you should update your question to be more specific. – Jami Gibbs Commented Dec 26, 2016 at 13:15
Add a comment  | 

1 Answer 1

Reset to default 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 );

本文标签: bbpressAvatar picture does not display when using getavatar