首页 > 成长点滴 > wordpress显示摘要

wordpress显示摘要

2009年8月22日 luo

一个初使用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…)’)); ?>覆盖。

分类: 成长点滴 标签:
  1. 2009年11月3日16:45 | #1

    i like this site. i added on my bookmark i thanks

  2. luo
    2009年11月11日22:14 | #2

    thanks!

  3. lv jun yong
    2010年6月23日14:08 | #3

    i like the site, thank you, i believe i will learn many here.

  1. 本文目前尚无任何 trackbacks 和 pingbacks.
本文的评论功能被关闭了.