Categories
Wordpress

How to Display Author Avatar Within Posts or Pages in WordPress

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.

By Praveen Anaparthi

11+ years of IT industry experience holding a wide range of skill sets and roles with significant work on PHP, Node.js, Python, Ruby, Docker, React.js, Microsoft Azure, Azure DevOps, Windows PowerShell, Shell script, Jenkins, MongoDB, SQL, MySQL, Apache, Nginx. etc. It is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.

Leave a Reply

Your email address will not be published.