31
May
May
如果一篇文章过于长,则首页占据的页面也就非常的长了,这样不利于阅读。我查了一下,找到了两种方法来实现首页显示摘要的方法。
1. 使用more标签
在你的文章中插入<!–more–>,这样就不用修改index.php了,而且修改为the_excerpt不好,文章中链接在首页中全部失效。
<!–more–>应该是官方推荐的方法,wordpress自己带的tinymce有个按钮可以直接插入<!–more–>
但是奇怪的是在我这个模板里面添加这个后,侧边栏会自动跑到整个文章列表的下面,而换用其他的模板就不会有这个问题。具体的原因不太清楚,解决方法我还在思考中。据说是因为是后来添加的 <!–more–> 在可视化的编辑模式下,写完日志再添加很容易错误地将 <!–more–> 插在一些定位元素中间,使得首页显示中个别元素封闭不完整造成错位。
2.使用the_excerpt标签
修改index.php 和 其他相关页面的代码:
将
PHP:
<?php the_content(’Read the rest of this entry &raquo;’); ?>
替换成:
PHP:
<?php the_excerpt() ?><br/><small><a href="<?php the_permalink(); ?>">Read full post…</a></small>
缺点:可能导致部分plugin失效;文中链接不会在摘要中显示。
