I would like to display the avatar of a user.

https://i.sstatic.net/99nOA.jpg I want to do custom styling, such as the circled avatar.

I have read there is code, and I am assuming this is the one I am wanting to use, I am not exactly sure where the code is supposed to go.

    global $current_user;
    if ( is_user_logged_in() ):
        echo get_avatar( $current_user->ID, 64 );

1 Answer 1


Hey pass the current user email id in get_avatar() function if user is logged in like this.

if ( is_user_logged_in() ) {
    $current_user = wp_get_current_user();
    if ( ($current_user instanceof WP_User) ) {
        echo get_avatar( $current_user->ID, 32 );

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.