View Single Post
  #1   IP: 222.184.47.106
Old 2009-02-02, 03:24 AM
car car is offline
高级会员
 
Join Date: 2006-05-14
Posts: 534
car 正向着好的方向发展
Default 在WordPress首页和目录页显示摘要的方法

在WordPress系统中,默认的首页和目录页使用的书全文输出,这对于文章内容较长的博客来说很不方面,下面我介绍一个方法,可以简单的实现在WordPress首页和目录页显示摘要而非全文。

  首先找到wp-content/themes下你使用的模板目录,查找目录中的文件,如果有home.php则修改home.php,没有的话就修改index.php,找到<?php the_content(); ?>这一行,将其修改为以下代码:

<?php if(is_category() || is_archive() || is_home() ) {
the_excerpt();
} else {
the_content('Read the rest of this entry &raquo;');
} ?>
<div class="details"><div class="inside"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> so far | <a href="<?php the_permalink() ?>">Read On &raquo;</a></div></div>

转载自月光博客 [ http://www.williamlong.info/ ]
Reply With Quote