How to Display Author’s Gravatar on Single Post in WordPress

Here’s a tiny WordPress code snippet which allows the developers to display Post Author’s Gravatar image on individual post. In this code we are using get_avatar() function.

<?php echo get_avatar( get_the_author_meta( 'ID' ), '80' ); ?>

Where the get_the_author_meta( ‘ID’ ) function will return author ID for the author of current post and 80 is the height and width of image the above code will generate. You can also pass Author’s email address as first parameter instead of Author’s ID.

Useful Read: How to Change Author URL Base in WordPress

Leave a Comment.