在WordPress首頁和目錄頁顯示摘要的方法




在WordPress系統(tǒng)中,默認的首頁和目錄頁使用的書全文輸出,這對于文章內容較長的博客來說很不方面,下面我介紹一個方法,可以簡單的實現(xiàn)在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>
這時,你的WordPress首頁和分類就顯示為摘要信息而不是全文信息了。
這段代碼可以在你的首頁、存檔頁、目錄頁使用摘要輸出,使用摘要輸出后,整個WordPress的重復內容就少多了,很利于搜索引擎優(yōu)化。
如用戶不想修改代碼,可以安裝使用這個插件來實現(xiàn)首頁摘要顯示的功能。