首页 > 建站 > wordpress显示文章摘要的方法

wordpress显示文章摘要的方法

2009年4月12日

wordpress的很多主题,在主页中都无法显示文章摘要,虽然有很多插件可以完成这一功能,但没有下面这个方法使用方便。其实问题就是出现在

1
<?php the_content(); ?>

这行代码中。根据自己所用的主题,找到home.php,如果没有就找到index.php,找到

1
<?php the_content(); ?>

这句代码,将其修改为:

1
2
3
4
5
6
7
8
9
10
11
12
<?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>

如果自己的主题没有category或者archive页面,可根据实际情况修改。
这样使各个页面都以文章摘要的形式输出,不仅使自己页面看上去整洁,也有利于搜索引擎人优化。

作者: feeloc 分类: 建站 标签: ,
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.