WordPress默认没有摘要功能,这就导致首页和目录页面全文输出.这对于大多数国人来说,浏
览十分不便.
因为全文输出会拉长WordPress首页和目录页,不但影响浏览,而且会减慢浏览速度.
以下yesure给大家介绍一下WordPress首页和目录页摘要的解决方案.
修改当前主题下的index.php文件,找到<?php the_content(); ?>这一行,当然有的WordPress博客的主题中可能含有其他的字符,比如blinux有一个WordPress博客的是
1 |
<?php the_content(__('Continue Reading »','ml')); ?>
|
直接将这一行替换为下面的代码:
1 2 3 4 5 |
<?php if(is_category() || is_archive() || is_home() ) {
the_excerpt();
} else {
the_content('Read the rest of this entry »');
} ?>
|
或者改成这样也可以
<?php if(is_category() || is_archive() || is_home() ) {
the_excerpt();
} else {
the_content(‘Read the rest of this entry »’);
} ?>
<div><div><?php comments_popup_link(‘No Comments’, ’1 Comment’, ‘% Comments’); ?> | <a href=”<?php the_permalink() ?>”>阅读全文»</a></div></div>
这样wordpress首页摘要就搞定了,实现了WordPress 本土化.
Good. Try it