就我发现使用the_excerpt()而言,没有办法做到这一点。
还有一个类似的StackOverflow问题here。
我发现要做的唯一事情就是写一个新的函数来获取这个表达式的地方。将以下代码的一些变体放入functions.php并调用limit_content($ yourLength)而不是the_excerpt()。
function limit_content($content_length = 250, $allowtags = true, $allowedtags = '') {
global $post;
$content = $post->post_content;
$content = apply_filters('the_content', $content);
if (!$allowtags){
$allowedtags .= '<style>';
$content = strip_tags($content, $allowedtags);
}
$wordarray = explode(' ', $content, $content_length + 1);
if(count($wordarray) > $content_length) {
array_pop($wordarray);
array_push($wordarray, '...');
$content = implode(' ', $wordarray);
$content .= "</p>";
}
echo $content;
}
(功能信用:fusedthought.com)
也有“先进摘录”插件提供的功能这样就可以查询到。
这仅仅是为我工作的代码...谢谢! – 2013-09-20 12:49:22