There are one-to-many times when you wish to show a short introduction of the author bio instead of the complete author byline. Well, in order to achieve this, all you have to do is to simply copy and paste the following snippet into your theme’s functions.php file.
1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php 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')); $authorDescriptionShort = wp_trim_words(strip_tags(get_the_author_meta('description')), $word_limit, $txt_end.'<br /> '.$more_txt.' <a href="'.$authorUrl.'">'.$authorName.'</a>'); return $authorDescriptionShort; } ?> Remember a thing more, once added the above snippet, add the following line of code at the place where you want to display a short introduction of the author byline: <?php if (function_exists('author_excerpt')){echo author_excerpt();} ?> |
Snippet Source/Credit: Tim Marcher