wordpress获取文章摘要函数the_excerpt()
- 1,060
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');
声明:博客中如无特殊说明或标注的文章均为博客原创文章,部分文章来源互联网,如有侵犯您的版权,或者对零分博客发布的文章有异议,请来信告知删除、修改,如您有好的建议或者意见也可以来信,谢谢!










