Filter hook 'wp_trim_words'

in WP Core File wp-includes/formatting.php at line 4087

View Source

wp_trim_words

Filter Hook
Description
Filters the text content after words have been trimmed.

Hook Information

File Location wp-includes/formatting.php View on GitHub
Hook Type Filter
Line Number 4087

Hook Parameters

Type Name Description
string $text The trimmed text.
int $num_words The number of words to trim the text to. Default 55.
string $more An optional string to append to the end of the trimmed text, e.g. ….
string $original_text The text before it was trimmed.

Usage Examples

Basic Usage
<?php
// Hook into wp_trim_words
add_filter('wp_trim_words', 'my_custom_filter', 10, 4);

function my_custom_filter($text, $num_words, $more, $original_text) {
    // Your custom filtering logic here
    return $text;
}

Source Code Context

wp-includes/formatting.php:4087 - How this hook is used in WordPress core
<?php
4082  	 * @param string $text          The trimmed text.
4083  	 * @param int    $num_words     The number of words to trim the text to. Default 55.
4084  	 * @param string $more          An optional string to append to the end of the trimmed text, e.g. &hellip;.
4085  	 * @param string $original_text The text before it was trimmed.
4086  	 */
4087  	return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text );
4088  }
4089  
4090  /**
4091   * Converts named entities into numbered entities.
4092   *

PHP Documentation

<?php
/**
	 * Filters the text content after words have been trimmed.
	 *
	 * @since 3.3.0
	 *
	 * @param string $text          The trimmed text.
	 * @param int    $num_words     The number of words to trim the text to. Default 55.
	 * @param string $more          An optional string to append to the end of the trimmed text, e.g. &hellip;.
	 * @param string $original_text The text before it was trimmed.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/formatting.php
Related Hooks

Related hooks will be displayed here in future updates.