This code is very useful if you have a WordPress website with multiple authors. The code will display a section with your gravatar, name and a little bio (the one you fill out in your user profile). This way, when people read an article written by you, they can see your info.
If you want this to appear on posts, you can add this snippet to single.php:
<div class="author-box">
<div class="author-pic"><?php echo get_avatar( get_the_author_email(), '100' ); ?></div>
<div class="author-name"><?php the_author_meta( "display_name" ); ?></div>
<div class="author-bio"><?php the_author_meta( "user_description" ); ?></div>
</div>
Feel free to style the classes (author-box, author-pic, author-name and author-bio) as you see fit on your CSS. The ‘100’ you see on the get_avatar function is the width and height of the gravatar. If it’s 100, then it would be 100×100, you can change it to any number.
If you have any questions, please let me know!
Thank you! I am a complete novice when it comes to code-writing so I’ll take all the help I can get. This will be really useful if I ever have guest posts.
You’re welcome Corinne, I’m glad this tutorial was useful!
Thanks! This is a very useful article, especially if you have a multi-author blog.
You’re welcome Rita, glad you liked it!
What does it look like, and what does it look like when it is done? and what part do you fill in? thank you for your help?
It depends on the styling you give it using CSS, but you should see the avatar to the left, then the name and the bio description the user filled out on their profile. You add the snippet wherever you want it to show up. I suggest you add it after the post body content but before the user comments. I will edit the tutorial as soon as possible and add a preview of how it looks. Have a great day Aida!