[转]让wordpress博客首页显示文章摘要
[总点击:1042次]一直很不喜欢wp在我的主页上全文显示文章,于是乎请教于google老师,终于功夫不负有心人,最终让我给找着一个插件: wp-CJK-excerpt
以下来源于作者博客:
Wordpress显示文章摘要插件wp首页和目录页显示摘要的方法
Yskin’s wp-CJK-excerpt 1.3 为WordPress用户提供更好的摘要算法,以解决WordPress默认摘要算法只考虑西方语言的不足。使用这个插件可以很好地显示文章摘要。 作者: Yskin 的网站坏了,找了半天才找到下载地址:
wp-CJK-excerpt 1.3 下载地址
要修改模板文件index.php页面中的下面这行代码:<?php the_content(’Read the rest of this entry ?’); /*引号中也有可能是其它内容*/ ?>
修改这一行为:<?php the_excerpt(); ?>
对于没有single.php页面的,还需要自建一个single.php文件,添加如下代码:<?php if (is_single()) { ?>
<?php the_content(’Read the rest of this entry ?’); ?>
<?php } else { ?>
<?php the_excerpt(); ?>
<?php } ?>
这样就可以了。此外,对于K2主题,是修改theloop.php文件,找到
<?php the_content(sprintf(__(’Continue reading \’%s\”, ‘k2_domain’), the_title(”, ”, false)));?>
然后改成<?php if (is_single()) { ?>
<?php the_content(sprintf(__(’Continue reading \’%s\”, ‘k2_domain’), the_title(”, ”, false)));?>
<?php } else { ?>
<?php the_excerpt(); ?>
<?php } ?>
就可以了。问一个问题:为什么我在配制完成后只在主页里能看到摘要,而在Categories和Archives中仍是全文??
谢谢~~回答:在Categories和Archives相应模板里也要改一下
经过试验感觉不错,在写文章的时候如果你自己有写摘要,那么就会显示你自己的摘要,如果没有就会给你自动生成一个摘要。
生活理财网为您全方位提供财经资讯及全球金融市场行情,覆盖股票、基金、期货、股指期货、外汇、债券、保险、银行、黄金、理财、股吧、博客等财经综合信息