Function Reference/wp trim words
Description
This function trims text to a certain number of words and returns the trimmed text.
Usage
<?php $trimmed = wp_trim_words( $text, $num_words = 55, $more = null ); ?>
Parameters
- $text
- (string) (required) Text to trim
- Default: None
- $num_words
- (integer) (optional) Number of words
- Default: 55
- $more
- (string) (optional) What to append if $text needs to be trimmed.
- Default: '…'
Return Value
- (string)
- Trimmed text.
Change Log
Source File
wp_trim_words() is located in wp-includes/formatting.php.
Related
How to use wp_trim_words in WordPress