1. 当前位置:
  2. 首页
  3. »
  4. 教程
  5. »
  6. wordpress获取文章摘要函数the_excerpt()

wordpress获取文章摘要函数the_excerpt()

零分 1,304

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

手动设置摘要,编写右边-文章-摘要。

wordpress获取文章摘要函数the_excerpt()

设置文章摘要的截取长度,在主题的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');
头像
支持作者
联系微信二维码
0%