WordPress实现自动添加more标签截断文章

发布于 2012-06-14  199 次阅读


要修改的为index.php文件,在修改它之前,最好能够先把它的内容备份一下(复制其内容到一个txt文件中,以免修改失败,无法复原index.php文件)。

然后找到其中的一句:

<!--?php the_content(__(); ?-->

替换为:

 <p>
 <?php echo mb_strimwidth(strip_tags(apply_filters(‘the_content’, $post->post_content)), 0, 200,"……"); ?>
 <a href="<?php the_permalink() ?>" rel="nofollow">阅读全文</a>
 </p>

 

其中的200是截取的字符数量,可以自行予以调整。