标签存档: 摘要

wordpress显示摘要

一个初使用wordpress的同学都会问的问题,如何在wordpress的首页中只显示文章的摘要?
在不使用任何hack和plugin的情况下,有两种方式可以实现:

使用the_excerpt标签
使用方法,
打开你使用的theme中的index.php,查找

<?php the_content(__(‘(more…)’)); ?>

<?php the_content(); ?>
修改为

<?php if(!is_single()) {
the_excerpt();
} else {
the_content(__(‘(more…)’));
} ?>
保存
现在你的wordpress,除非打开单个post,其他情况下都是显示摘要。
Tips:在写一篇post的时候,如果你在Optional Excerpt中填写了内容,摘要就显示此部分内容。其他情

况下,wordpress都会自动截取Post开头的部分内容显示出来。
缺点:可能导致部分plugin失效;文中链接不会在摘要中显示。

使用more标签
使用方法,
看下例

一个初使用wordpress的同学都会问的问题,如何在wordpress的首页中只显示文章的摘要?
在不使用任何hack和plugin的情况下,有两种方式可以实现:
使用the_excerpt标签
使用方法,<!–more–>
打开你使用的theme中的index.php,查找

在<!–more–>在之前的内容非单篇post的情况下作为摘要显示。查看效果
Tips:如何在quicktags栏中显示more按钮。
在你使用的theme的index.php中查找<?php the_content(); ?>,如找到,用<?php the_content(__(’

(more…)’)); ?>覆盖。