WordPress does not provide a lot of ways to customize your profile in the admin area. If your website or blog is multi-authored, placing the author’s bio at the end of their individual posts is a way to give them recognition and provide information to your visitors about that author without the need to create a page dedicated to them. You can add an author’s bio by using the following technique below:
First step is to add the code below in your functions file:
function wpb_author_info_box( $content ) {
global $post;
// Detect if it is a single post with a post author
if ( is_single() && isset( $post->post_author ) ) {
// Get author’s display name
$display_name = get_the_author_meta( ‘display_name’, $post->post_author );
// If display name is not available then use nickname as display name
if ( empty( $display_name ) )
$display_name = get_the_author_meta( ‘nickname’, $post->post_author );
// Get author’s biographical information or description
$user_description = get_the_author_meta( ‘user_description’, $post->post_author );
// Get author’s website URL
$user_website = get_the_author_meta(‘url’, $post->post_author);
// Get link to the author archive page
$user_posts = get_author_posts_url( get_the_author_meta( ‘ID’ , $post->post_author));
if ( ! empty( $display_name ) )
$author_details = ‘
About ‘ . $display_name . ‘
‘;
if ( ! empty( $user_description ) )
// Author avatar and bio
$author_details .= ‘
‘ . get_avatar( get_the_author_meta(‘user_email’) , 90 ) . nl2br( $user_description ). ‘
‘;
$author_details .= ‘
View all posts by ‘ . $display_name . ”;
// Check if author has a website in their profile
if ( ! empty( $user_website ) ) {
// Display author website link
$author_details .= ‘ | Website
‘;
} else {
// if there is no author website then just close the paragraph
$author_details .= ‘
‘;
}
// Pass all this info to post content
$content = $content . ‘
‘ . $author_details . ‘
‘;
}
return $content;
}
// Add our function to the post content filter
add_action( ‘the_content’, ‘wpb_author_info_box’ );
// Allow HTML in author bio section
remove_filter(‘pre_user_description’, ‘wp_filter_kses’);
Now to make it even nicer, you can use this basic custom CSS:
.author_bio_section{
background: none repeat scroll 0 0 #F5F5F5;
padding: 15px;
border: 1px solid #ccc;
}
.author_name{
font-size:16px;
font-weight: bold;
}
.author_details img {
border: 1px solid #D8D8D8;
border-radius: 50%;
float: left;
margin: 0 10px 10px 0;
}