How to display author avatar in Wordpress 5

Updated at 08-Feb-2022, By samar

How to display author avatar in Wordpress 5

Hello everyone, in this post we will examine how to solve the "How to display author avatar in Wordpress 5" programming puzzle.

You can display author avatar in Wordpress. You have to call the get_avatar() method to get the author avatar in posts or pages in Wordpress.
  • Display author avatar in wordpress 5

    --PATH wp-content\themes\<twentytwentyone>\<header>.php
    echo get_avatar($id_or_email = get_the_author_meta('user_email'),  
                    $size = 50, 
                    $args = array('class' => array( 'avatar', 'img-circle')));
    

    You can use the get_avatar() method to get the author avatar in wordpress. In my case, I have used it in my wp-content\themes\twentytwentyone\header.php file to get the author avatar in my website header section. You can use it anywhere as per your requirement.

Back to code snippet queries related wordpress