wp_trim_words
云策文档标注
概述
wp_trim_words 是一个 WordPress 过滤器钩子,用于在文本被裁剪到指定单词数后过滤内容。它允许开发者修改裁剪后的文本输出。
关键要点
- 这是一个过滤器钩子,用于处理文本裁剪后的内容。
- 接受参数包括裁剪后的文本、单词数、可选追加字符串和原始文本。
- 常用于自定义文本裁剪行为,如修改追加符号或调整输出格式。
代码示例
return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text );注意事项
- 此钩子自 WordPress 3.3.0 版本引入。
- 与 wp_trim_words() 函数相关,用于文本裁剪功能。
原文内容
Filters the text content after words have been trimmed.
Parameters
$textstring-
The trimmed text.
$num_wordsint-
The number of words to trim the text to. Default 55.
$morestring-
An optional string to append to the end of the trimmed text, e.g. ….
$original_textstring-
The text before it was trimmed.
Source
return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text );
Changelog
| Version | Description |
|---|---|
| 3.3.0 | Introduced. |