我们用echo get_the_excerpt()获取摘要发现长度不符合我们预期,最讨厌的是后面还加个[…]让人非常难受!!下面我们来干掉它
我们来自定义函数,然后通过钩子进行过滤
改变默认的长度(默认55):
我们在functions.php中添加如下代码:
function new_excerpt_length($length) { return 150; } add_filter('excerpt_length', 'new_excerpt_length');
改变最后的[…],修改成我们自己想要的样式:
function new_excerpt_more($more) { return '...'; } add_filter('excerpt_more', 'new_excerpt_more');
评论前必须登录!
注册