Dukeo » WordPress » Author Bio: How To Insert It At The Bottom Of Each Post

Author Bio: How To Insert It At The Bottom Of Each Post

Steven 4 responses WordPress

Basically, there are two ways to automatically insert the Author Bio at the bottom of each blog post. While the easiest is to edit the single.php file in your WordPress theme folder, it’s not the cleanest way of doing it.

Today, I’d like to share another method to automatically insert author bio at the bottom of each blog post: using a WordPress hook.

All you need to do is pasting the following code in the functions.php file of your WordPress theme:

function get_author_bio($content='') {
    global $post;
    $post_author_name=get_the_author_meta("display_name");
    $post_author_description=get_the_author_meta("description");
    $html="<div class='clearfix' id='about_author'>\n";
    $html.="<img width='80' height='80' class='avatar' src='http://www.gravatar.com/avatar.php?gravatar_id=".md5(get_the_author_email()). "&default=".urlencode($GLOBALS['defaultgravatar'])."&size=80&r=PG' alt='PG'/>\n";
    $html.="<div class='author_text'>\n";
    $html.="<h4>Author: <span>".$post_author_name."</span></h4>\n";
    $html.= $post_author_description."\n";
    $html.="</div>\n";
    $html.="<div class='clear'></div>\n";
    $content .= $html;
    return $content;
}
add_filter('the_content', 'get_author_bio');

If you enjoyed this article,
Get email updates

Join for Free »

4 Comments

  1. Hey Steven I don’t know if I do it the same way but I 100% suggest anyone wanting guest post article follow your suggestion. since I’ve added an author bio I’ve gotten tons more guest posts and I love it.

    1. It’s important to remember why people are submitting guest posts… They want backlinks and exposure for their own brand. It’s a win-win situation since you get valuable content for your audience in return :)

  2. I can’t understand why you say adding this way is cleaner than adding it in your single.php

    1. Because once you’ve installed a lot of different tweaks on your WordPress-based website like shortcodes, mods, custom functions, in your functions.php file. All you need to do when you migrate to a new WordPress theme is to copy the old functions.php to the new theme’s folder and you’re done. Which is a lot more practical than copying/pasting pieces of code from various files in various places.