Warning: Trying to access array offset on false in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 216
wp_trim_excerpt() - 如果需要,从内容中生成摘录 - WordPress函数 - WordPress动力
当前浏览:首页 / WordPress函数 / wp_trim_excerpt()

wp_trim_excerpt( string $text = '', WP_Post|object|int $post = null )

如果需要,从内容中生成摘录


Warning: Undefined array key -1 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 185

Warning: Undefined array key 3 in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/reference-cat.php on line 186

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "7daa69091da2c3c5a00b72a3f5f57880" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

Warning: Undefined variable $searchand in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 154

Warning: Undefined array key "3fee5cc6d9a32b53431b1ef4a5ca63c8" in /www/wwwroot/www.wpdongli.com/wp-content/themes/WPdongli/functions/wp.php on line 223

excerpt 摘要more...

trim


描述

返回最多55个单词,必要时添加省略号。

插件、主题使用‘excerpt_length’过滤器可以修改55字限制。插件、主题使用‘excerpt_more’过滤器可以修改“[…]”字符串。


参数

$text

(string)(可选) 摘录。如果设置为空,则生成摘录。

默认值: ''

$post

(WP_Post|object|int)(可选) WP_Post实例或文章ID/对象。

默认值: null


返回

(string) 摘录



源码

查看源码 官方文档


更新日志

版本描述
5.2.0添加了$post参数。
1.5.0开始引入

使用示例

  • 示例1

    如果我们已经有了摘录,只想将其缩减为较小的量,请使用以下方法:

    	echo "Here is short info about post: \n" . wp_trim_excerpt($excerpt);
    

    如果没有,您只需要使用这样的代码,请注意$id是文章的id

    	echo "Here is short info about post: \n" . wp_trim_excerpt("",$id);