X

Author Bio Excerpt

When you like to show a short intro of the author bio of a post and not his complete bio. Use this code snippet to make an excerpt of the bio, with a link to the author page, where you can show the full bio.

Usage:

Code Snippet:

// Add this code snippet to the single.php file where you like to display the author bio excerpt. <br />
echo author_excerpt();

Code Snippet:

// Paste the code below to the functions.php file inside the theme directory you're using.
function author_excerpt (){	                     					
	$word_limit = 20; // Limit the number of words
	$more_txt = 'read more about:'; // The read more text
	$txt_end = '...'; // Display text end 
	$authorName = get_the_author();
	$authorUrl = get_author_posts_url( get_the_author_meta('ID'));
	$authorDescription = explode(" ", get_the_author_meta('description'));
	$displayAuthorPageLink = count($authorDescription) > $word_limit ? $txt_end.' '.$more_txt.' <a href="'.$authorUrl.'">'.$authorName.'</a>' : '' ;
	$authorDescriptionShort = array_slice($authorDescription, 0, ($word_limit));
	return (implode($authorDescriptionShort, ' ')).$displayAuthorPageLink; 		
}

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!