wordpress获取文章摘要函数the_excerpt()
wordpress获取文章摘要函数the_excerpt(),直接输出get_the_excerpt(),没有设置摘要时默认截取文章前55个字符,默认结尾添加[…]。
手动设置摘要,编写右边-文章-摘要。

设置文章摘要的截取长度,在主题的functions.php中加入
/**设置摘要长度**/
function excerpt_length($length) {
return 100; // 设置为30个单词
}
add_filter('excerpt_length', 'excerpt_length');
修改文章摘要截取结尾[…]
/**设置摘要结尾**/
function excerpt_more($more) {
return '...';
}
add_filter('excerpt_more', 'excerpt_more');
