在wp-includes目录下找到formatting.php,里面有这样一个函数:
function wp_trim_excerpt($text) {
global $post;
if ( " == $text ) {
$text = get_the_content(");
$text = apply_filters(‘the_content’, $text);
$text = str_replace(‘]]>’, ‘]]>’, $text);
$text = strip_tags($text);
$excerpt_length =55;
$words = explode(‘ ‘, $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, ‘[...]‘);
$text = implode(‘ ‘, $words);
}
}
return $text;
}
将$excerpt_length =55改为你需要截取的字数。这样就可以修改首页截取的简洁字数
» 转载请注明来源:《WordPress中修改默认摘要the_excerpt()的长度》
» 本文的链接地址:http://www.yshe.net/post/1149.html