我正在使用Wordpress 3.9.2,在wp_trim_words
作用它似乎将字符串缩减为X个字符,而不是X个单词。
Example
将以下内容放入模板文件中:
<?php
$str = "Imagine discovering a secret language spoken only online by a knowledgeable and learned few. Over a period of weeks, as you begin to tease out the meaning of this curious tongue and ponder its purpose, the language appears to shift in subtle but fantastic ways, remaking itself daily before your eyes. And just when you are poised to share your findings with the rest of the world, the entire thing vanishes.";
$str_excerpt = wp_trim_words($str, $num_words = 5, $more = \'...\' );
echo $str_excerpt;
?>
在我的浏览器中,我看到的输出为
Imagi...
. 但据我所知,这不是它应该起的作用
the docs:
描述
此函数用于将文本修剪为一定数量的单词,并返回修剪后的文本。
用法
$trimmed=wp\\u trim\\u words($text,$num\\u words=55,$more=null);
我使用的主题中是否有导致这种行为的设置或其他原因?