Avatar picture does not display when using get_avatar

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.

Topic gravatar avatar bbpress Wordpress

Category Web


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 );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.