Nested PHP wp_trim_words
-
I’m creating a page template with a list of authors and next to each is their photo, name, and bio. I want the bio to display a set number of characters followed by a ‘Read more’. The code below does work however I’m unable to replace ‘this text does get trimmed’ with
the_author_meta('description', 3)
(3 being one of the author ID’s.) I have a feeling it’s just a matter of nesting PHP however I’m not sure how.Thoughts? Thanks!
<?php $field = 'this text does get trimmed'; $trimmedfield = wp_trim_words( $field, $num_words = 1, $more = '<a href="'. get_permalink() .'"> ...Read More</a>' ); echo '<p>' . $trimmedfield . '</p>'; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Nested PHP wp_trim_words’ is closed to new replies.