在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 »');
} ?>
<div class="details"><div class="inside"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> so far | <a href="<?php the_permalink() ?>">Read On »</a></div></div>
转载自月光博客 [
http://www.williamlong.info/ ]