如何在wordpress中显示摘要
2009-08-26 at 11:14 上午 宽宽最近在优化一个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>
使用摘要以后,重复内容会比较少,利用搜索引擎优化,用户对于感兴趣的话题想了解更多的话,另一方面也可以增加用户访问的pv。