通常情况下,WordPress 文章摘要的长度是默认的 55 个字符,除非你的主题作者修改过,这样你只有在自己主题中实现的地方进行修改。如果没有,你可以通过代码修改让它固定显示地更长些或短些。具体方式是在主题的 functions.php 中添加下面的代码即可:
/* 功能描述: 自定义摘要长度 功能介绍页面: https://www.ivicos.com/124.html */ function custom_excerpt_length( $length ) { return 120; } add_filter( 'excerpt_length' , 'custom_excerpt_length' , 999 ); function new_excerpt_more( $more ) { global $post; return ' <a target="_blank" href="'. get_permalink( $post->ID ) . '"></a>'; } add_filter( 'excerpt_more' , 'new_excerpt_more' );
好了,WordPress 自定义摘要长度 就分享到这里,非常感谢你的来访。如果你喜欢本站,请不要忘记收藏本站,以便下次继续访问;也可以 关注站长微博 随时获取最新动态。你的支持就是我最大的动力!
转载请注明:爱维科斯 » WordPress 自定义摘要长度
如果文章对你有帮助,欢迎点击上方按钮打赏作者