WordPress显示摘要并修改”Read the rest of this entry”
日期 2008-08-30   分类 计算机与Internet   作者 DiDi   标签 标签:

同样不需要安装插件

使用more标签 (缺点:每次都要加一下这个东西,不灵活只能一刀切。优点:方法比较正规不需要改动模版)

在你需要截断的地方(就是你的编辑框),点“插入‘更多’标签”,或者在HTML源代码那里添加 <!–more–>

默认的显示字样一般是“Read the rest of this entry…”,这时我们可以修改这段内容,让其显示为中文,例如:”展开阅读…”。

这时你需要修改index.php,找到 <?php the_content(’ Read the rest of this entry »’); ?>, 把红色的内容替换成你想要的内容就行了~

PS:如果您使用 <!–more–> 功能,在RSS中是不会截断的,只是会在页面上显示 <!–more–>代码之前的内容 ,如果你的文章有图片或者音视频的话,这样对页面的加载速度会有帮助的。

还有种方法

使用the_excerpt标签 (缺点:需要改动模版,而且显示的是纯文本。优点:一劳永逸直接把想要的部分来做摘要)

使用方法,注意是编辑你的模版中(wp-contant/themes/你的模版/index.php) 文件)。 

找到

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

<?php the_content(); ?>

修改为:

  1. <?php if(!is_single()) {
  2.      the_excerpt();
  3.      } else {
  4.      the_content(__(‘(more…)’));//或者<?php the_content(); ?>
  5.   } ?>

现在你的wordpress,除非打开单个post,其他情况下都是显示摘要。

喜欢本文,就收藏到: Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网

  1. 2条评论 关于 “WordPress显示摘要并修改”Read the rest of this entry””

  2. sf 发表于2009-12-16

    为什么我用的the_excerpt依旧是全文啊…… #7

    Reply

  3. fefe 发表于2010-02-06

    Gucci

    Reply

#9 #8 #7 #6 #5 #49 #48 #47 #46 #45 #44 #43 #42 #41 #40 #4 #39 #38 #37 #36 #35 #34 #33 #32 #31 #30 #3 #29 #28 #27 #26 #25 #24 #23 #22 #21 #20 #2 #19 #18 #17 #16 #15 #14 #13 #12 #11 #10