How To Display Author Avatar In Post
In WordPress you can assign avatars to your authors, but if you have avatars then you need to be able to use them.
In this snippet you will see how you can display the author avatar in the post display. Wordpress has a built in function
<?php echo get_avatar( $id_or_email, $size, $default, $alt ); ?>
You will use this to display the author avatar, by using the following snippet.
<?php echo get_avatar( get_the_author_email(), '128', '/images/no_images.jpg', get_the_author() ); ?>
Learn how to code with Treehouse
- Learn projects with access to 1000+ videos
- Practice live with our Code Challenge Engine
- Get help in our members-only forums
Join the weekly newsletter
Sign up for our newsletter. You'll be updated on new tutorials as they come available.
Subscribe today and get a 50% discount code to Paulund