在输出文章摘要的时候用
<?php echo get_the_excerpt(); ?>//这样输出的文章摘要没有带P标签
同样的道理,如果想调用内容不带p标签,可以用
<?php echo get_the_content(); ?>
然后使用PHP自带的截取
<?php mb_strimwidth($text, 0, 120, '...') ?>//截取文字后面加上省略号
最后的代码就是这样
<?php $text=get_the_excerpt(); echo mb_strimwidth($text, 0, 120, '...');?>
本文介绍如何在WordPress中使用PHP代码自定义文章摘要和内容截取,包括去除P标签及添加省略号的方法。
1262

被折叠的 条评论
为什么被折叠?



