I am using this code to get the meta for the current author in the loop.

 get_avatar( get_the_author_meta( 'ID' ), 120);

How can I modify this to get the meta for a particular user ID? I tried for example to get the image for userID: 4 but this didn't work.

get_avatar( get_the_author_meta( '4' ), 120);

1 Answer 1


The function get_the_author_meta('ID') will return the ID of the author for the current post.

That means this line should work.

get_avatar( get_the_author_meta( 'ID' ), 120);

This will not work

get_avatar( get_the_author_meta( '4' ), 120);

Because you are trying to get a property named '4' inside the user object and that property doesn't exist.

If you wanted to get the avatar for user 4 you would use.

get_avatar( 4, 120);

Because get_avatar takes either a $user_id or $email as the first parameter and the $size as the second.

On a final note the WordPress documentation uses, so check for a formatting error in your html.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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