Showing an Author Bio on a Post

Many blogs often include a small biography of the author/s at the bottom of a post. Here's how to add a bio box to the end of your posts. We'll be using the same thematic_post filter that we used above.

First, let's write our function—the pattern should be growing familiar to you by now! The first if statement checks to see if we're in a single post or a page (as we only want to display the author bio on the full view, and not in lists of posts). Assuming either of these conditions is true, our function then builds a div, a heading for the author's name, the author's Gravatar at a size of 50 pixels, and the bio from the author's WordPress profile. We then return the post content with the new div attached. Here's our function:

chapter_05/v5/wicked/functions.php (excerpt)

function wicked_showbio($content) { if (is_single()) {

$content .= '<div id="authorbio">';

Was this article helpful?

0 0

Post a comment