X

How to Show Author Bio Excerpt in WordPress

Snippets by IsItWP

Are you looking for a way to show a short intro of the author bio of a post and not the complete bio? While there’s probably a plugin for this, we have created a quick code snippet that you can use to show author bio excerpt in WordPress.

Instructions:

All you have to do is add this code to your theme’s single.php file:


// 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; 		
}

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 23 effective tips to get more email subscribers and how to increase maximum file upload size in WordPress.

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!