以下代码(来源)写入functions.php,即可首页全文输出改摘要输出,摘要字数需要在formatting.php中修改(参考1,2)。
/**
* Display the content in short words
*/
function dm_strimwidth($str ,$start , $width ,$trimmarker ){
$output = preg_replace('/^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$start.'}((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$width.'}).*/s','\1',$str);
return $output.$trimmarker;
}
/*控制摘要字数*/
function new_excerpt_length($length) {
return 150;
}
function new_excerpt_more($more) {
global $post;
return '<a href="'. get_permalink($post->ID) . '">......阅读更多</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
然而在原生主题twenty fifteen中未能生效,该主题需要通过其他方式实现。