You might have seen many of the websites having their Authors avatar next to the Post title of their Respective posts. its mostly seen in the Multi Authored blog doing it so. is not difficult but its Lot more easier to do in thesis we can add Authors avatar in thesis.
Now lets go and add the Authors Avatar next to the Post title so that our Beloved Authors get some more credits.
Installation :
- Login to your WordPress Dashboard
- Go to Thesis >> Custom File Editor
- Select custom_functions.php and add the below code :
function myavatar_post_title() { ?> <?php echo get_avatar( get_the_author_id() , 48 ); ?> <?php } add_action('thesis_hook_before_headline', 'myavatar_post_title');
- Now time to add the CSS in custom.css :
.custom .headline_area .avatar { float:left; border:3px solid #ddd; margin-right:1em; }
We have successfully added Avatar next to the post title now time to customize it.
Customization :
How to Show Avatar only on Home Page ?
To Show the Authors Avatar on Home page we will use WordPress Conditional Tag :
function myavatar_post_title() if( is_home()) { { ?> <?php echo get_avatar( get_the_author_id() , 48 ); ?> <?php } } add_action('thesis_hook_before_headline', 'myavatar_post_title'); |
How to change the Avatar ?
The avatar of the Author is pulled through Gravatar.com using the Authors Email ID. So to change the Avatar at Gravatar.
How to change the Border of avatar ?
Check the CSS we have added to custom.css just edit it.
How to show Avatar only on Post page ?
for showing Avatar on Post page we are going to use WordPress Conditional Tags again but this time instead of is_home() it will be is_single() i.e. :
function myavatar_post_title() if( is_single()) { { ?> <?php echo get_avatar( get_the_author_id() , 48 ); ?> <?php } } add_action('thesis_hook_before_headline', 'myavatar_post_title'); |
How to change the Size of the Avatar ?
to change the size of avatar find the Number “48” in the Code and replace it with any the Number of size you want of avatar.
Hope you like the New Looks of your site and Enjoyed reading this Thesis Customization.
Tyler says
Really great post, Ritesh. I implemented this in about five minutes. Thanks!
Rasel Rony says
nice tutorial, I’ve successfully added author avatar in my thesis themes