Are you looking for a way to display currently logged in users avatar in your theme? While there’s probably a plugin for this, we have created a quick code snippet that you can use to display avatar for currently logged in user with
get_avatar in WordPress.
To adjust the size of the avatar, you can change the number 64 within the
get_avatar function to default which is 96 and max size is 512.
All you have to do is add this code to your theme’s index.php file:
<?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user->ID, 64 ); ?>
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 28 best WordPress business themes for your website and how to create a custom user registration form in WordPress.