OK, this might be a duplicate, I was just unable to put my idea in proper search terms, sorry for that!
Is there a built-in function or template tag to get the first n
words of the content? I mean the_content()
.
Thanks!
1 Answer
Yep, wp_trim_words()
:
<?php $trimmed = wp_trim_words( $text, $num_words = 55, $more = null ); ?>
Or in your case:
<?php echo apply_filters( 'the_content', wp_trim_words( strip_tags( $post->post_content ), 55 ) ); ?>