Genesis Custom Author Box
I was looking for a custom solution to the Genesis Author Box. I didn’t find one.
I did find examples and bits and pieces.
First I used Greg Rickaby’s idea to add extra fields to the WordPress user profile.
http://gregrickaby.com/2011/01/add-new-contact-methods-to-wordpress.html
I used the first part of his code
[php]
remove_action(‘genesis_after_post’, ‘genesis_do_author_box_single’);
// Add/Remove Contact Methods
function add_remove_contactmethods( $contactmethods ) {
$contactmethods[‘twitter’] = ‘Twitter’;
$contactmethods[‘facebook’] = ‘Facebook’;
$contactmethods[‘linkedin’] = ‘Linked In’;
$contactmethods[‘flickr’] = ‘Flickr’;
// Remove Contact Methods
unset($contactmethods[‘aim’]);
unset($contactmethods[‘yim’]);
return $contactmethods;
}
add_filter(‘user_contactmethods’,’add_remove_contactmethods’,10,1);
[/php]
Then I combled this bit together
[php]
// Add Author Box
add_action(‘genesis_after_post_content’, ‘custom_author_box’);
function custom_author_box() {
echo ‘<div class="author-box">’;
echo get_avatar( get_the_author_id() , 100 );
echo ‘<h2>’;
the_author_meta( ‘display_name’, $userID );
echo ‘</h2>’;
echo ‘<p>’;
the_author_meta( ‘description’, $userID );
echo ‘</p>’;
echo ‘<div class="author-links">’;
echo ‘<ul>’;
echo ‘<li class="user_url"><a href="’;
the_author_meta( ‘user_url’, $userID );
echo ‘"><img src="/images/www32.png"></a></li>’;
echo ‘<li class="user_tw"><a class="user_tw" href="’;
the_author_meta( ‘Twitter’, $userID );
echo ‘"><img src="/images/twitter32.png"></a></l>’;
echo ‘<li class="user_fb"><a class="user_fb" href="’;
the_author_meta( ‘facebook’, $userID );
echo ‘"><img src="/images/facebook32.png"></a></li>’;
echo ‘</ul’;
echo ‘</div>’;
echo ‘</div>’;
}
[/php]
And sprinkled with a little bit of CSS
[css]
.author-links li {
width: 35px;
height: 35px;
float: left;
margin: 10px 15px 0 15px;
list-style-type: none;
}
[/css]
You can see it in action here -> www.landofgraciousliving.com
Thanks for this post, it’s just what I’ve been looking for. However, the author box is also showing up after my archives/search results. Any ideas?
Add this bit after function custom_author_box
if ( is_single() ):
or like this if you have extra custom post types
if ( is_single() && ‘post’ == get_post_type() ):
Works great! Thanks!