Now, I have decided to mess up a bit with thesis theme hooks and tweaks. Few days back I wrote about how to add social networking share buttons on thesis theme teaser box. This time I was looking for the code to add Author Avatar or Gravatar or author image, thumbnail before post title in thesis theme teaser box. The reason for doing this is that soon I will turn this into a multi-author blog. ( if you want to write for us , do contact me via contact form) So its a must heck for a multi author blog to show author images/thumbnails/avatars with their post titles.
Here is what I mean;
Code for Custom_functions.php file
Copy following code Into your thesis theme custom_functions.php file. But before you follow this let me reproduce here ‘standard warning”, which you will see, while doing this heck. Read carefully
Note: If you make a mistake in your code while modifying a PHP file, saving this page may result your site becoming temporarily unusable. Prior to editing such files, be sure to have access to the file via FTP or other means so that you can correct the error.
It’s a simple tweak, all you have to do is to copy and paste codes as instructed below;
If you are doing it through FTP software, which is always recommended, you know that your custom_functions.php file resides in your /www/wp-content/themes/thesis_18/custom folder. Open it, paste the code and save it.
Note: By defaultI have taken the avatar thumbnail image size at 40px in code below , you can change it according to your need.
/********* Author avatars*******************/
function byline_avatars() {
echo get_avatar(get_the_author_id(), 40);
}
add_action('thesis_hook_before_teaser_headline', 'byline_avatars');
function custom_body_class($classes) {
if (is_archive() || is_category()) {
$classes[] .= 'hide_meta';
}
return $classes;
}
add_filter('thesis_body_classes', 'custom_body_class');
/********* Author avatars*******************/
Code for custom.css file
Now select the custom.css file and paste the following code and save it. You can style it to your heart
if you know how to do it.
/*************Author Avatar*****************/
.custom .avatar {
float: left;
border-width: 2px; border-style: solid; border-color: #CCCCCC; padding: 3px; margin-bottom: 13px;
margin-right: 0.5em;
margin-bottom: 0.5em;
}
.custom.hide-meta .headline_meta {display:none;}
/*************Author Avatar*****************/
that’s all, you’re done, visit your thesis theme site and you can see author image with post title in thesis theme teaser box.
This is really very useful post for community bloggers. Thanks for share this with us !
Wow cool mate
a nice share
Good Share! TKS!
It means that now guest bloggers can also get identity if they post timely on a blog! which have multiple posting facility
Thanks shanker, i was looking for it
Hope it will do the job for you dude, Let me know you have any problem.
Thanks for the code Shankar
I am soon going to buy this great theme. Thanks a lot for the article. Bookmarked for future reference
Hello,
This works, but the avatars in comments get messed up. How can I do it so that they don’t get affected by this class?
I don’t think it has anything to do with comment avatars, just check it again
It’s the CSS.
Try changing “.custom .avatar {” to “.headline_area .avatar {” or something more specific to where the avatar is showing up.
Very useful, i placed the code as u said.. but its only showing in homepage… yet looking nice…thanks
Good to see it works for you
FWIW, in the 1.18 version of Thesis that I just installed I had to use a different hook: thesis_hook_before_headline
add_action(‘thesis_hook_before_headline’, ‘byline_avatars’);
hey thanx a lot its really amazing…..