By calling the get_avatar() method we can get the author’s avatar, below is the code snippet to display the author’s avatar on posts or pages in WordPress.
<?php
echo get_avatar( $id_or_email = get_the_author_meta( 'user_email' ),
$size = 50,
$args = array( 'class' => array( 'avatar', 'img-circle' ) ) );
?>
You can also use get_the_author_email()
function to get the post author email address.