wp_trim_words WordPress Filter Hook

The wp_trim_words hook is used to trim a string of words to a specified length. It is useful for content that needs to be cut off after a certain number of words, such as excerpts.

apply_filters( 'wp_trim_words', string $text, int $num_words, string $more, string $original_text ) #

Filters the text content after words have been trimmed.


Parameters

$text

(string)The trimmed text.

$num_words

(int)The number of words to trim the text to. Default 55.

$more

(string)An optional string to append to the end of the trimmed text, e.g. ….

$original_text

(string)The text before it was trimmed.


Top ↑

Source

File: wp-includes/formatting.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More