How to Add Author Avatar With Post Title in Thesis Teaser Box

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;

Author Thumbnail Thesis Teaser Box

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;

  • Login your WordPress admin
  • Choose ‘custom file editor’ under thesis options.
  • Select custom_functions.php file and click edit selected file.
  • Paste the below code

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.

15 Responses to “How to Add Author Avatar With Post Title in Thesis Teaser Box”

  1. Sumon says:

    This is really very useful post for community bloggers. Thanks for share this with us !

  2. Wow cool mate :) a nice share

  3. zehui says:

    Good Share! TKS!

  4. LED Signs says:

    It means that now guest bloggers can also get identity if they post timely on a blog! which have multiple posting facility

  5. Rajan Balana says:

    Thanks shanker, i was looking for it :)

  6. Swamykant says:

    Thanks for the code Shankar

  7. I am soon going to buy this great theme. Thanks a lot for the article. Bookmarked for future reference :)

  8. 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?

  9. Rohit says:

    Very useful, i placed the code as u said.. but its only showing in homepage… yet looking nice…thanks

  10. 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’);

  11. pawan kumar says:

    hey thanx a lot its really amazing…..