Wordpress Tricks

How to get Get author avatar for particular user inside the loop?

get Get author avatar for particular user inside the loop

wordpress
174Views

Hello, welcome to therichpost.com. In this post, I will tell you, How to get Get author avatar for particular user inside the loop? Like I always say WordPress is the best cms. 

Today In this post, we will get author avatar image in wordpress post loop and there are various methods and here are the working codes:
For comments:
<?php echo get_avatar( $comment, 32 ); ?>

For a post's author, in The Loop:
<?php echo get_avatar( get_the_author_meta( 'ID' ), 32 ); ?>

For a random email address:
<?php echo get_avatar( 'email@example.com', 32 ); ?>

For a specific user id:
<?php  
    $user_id = 2;
    echo get_avatar( $user_id, 32 ); 
?>

 There are so many tricks in wordpress and i will let you know all. Please do comment if you any query   related      to this post. Thank you. Therichpost.com

 

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

Positive SSL