How to add Author Avatar and Link it to Author Page in Thesis

by Sandeep on August 23, 2011

Thesis is one of the best frameworks available for WordPress. In this tutorial I am going to describe How to add Author Image to your single post page and link it to Author’s page in Thesis Theme. Author bio in the post page adds a special attraction to the post, because if a reader likes a post he will be interested to know more about that Author.

By doing this you can link an image of the author to Author’s Archive page, where all the posts written by a particular Author can be seen.

How to Add Author Avatar and Link it to Author Page in Thesis Theme

By pasting the below snippet, Author Image will be added in the post page and it be automatically linked to Author’s archives Page.

function custom_author_post_avatar(){
if(is_home() || is_single()){
if(get_query_var('author_name')){
$curauth = get_userdatabylogin(get_query_var('author_name'));
}else{
$curauth = get_userdata(get_query_var('author'));
}
?>
<div style="float:left;padding-right:10px;padding-bottom:10px;">
<?php $url = get_the_author_meta( 'user_login' ); ?>
 <?php $url = str_replace(' ' , '-', $url ); ?> 
<? echo "<a href=\"/author/".$url."\">".get_avatar( get_the_author_email(), '50' )."</a>"; ?>
</div>
<?
}
}
add_action('thesis_hook_before_headline', 'custom_author_post_avatar');

You can also make the add Author avatar for teasers on home page.

function custom_author_post_avatar_teaser(){
if(is_home()){
if(get_query_var('author_name')){
$curauth = get_userdatabylogin(get_query_var('author_name'));
}else{
$curauth = get_userdata(get_query_var('author'));
}
?>
<div style="float:left;padding-right:10px;padding-bottom:10px;">
<?php $url = get_the_author_meta( 'user_login' ); ?>
 <?php $url = str_replace(' ' , '-', $url ); ?> 
<? echo  "<a href=\"/author/".$url."\">".get_avatar( get_the_author_email(), '35' )."</a>"; ?>
</div>
<?
}
}
add_action('thesis_hook_before_teaser_headline', 'custom_author_post_avatar_teaser');

Download Thesis Theme

Leave a Comment

CommentLuv badge

Previous post:

Next post: