查看完整版本: 在WordPress首页和目录页显示摘要的方法

gamemaster 2008-9-30 17:19

在WordPress首页和目录页显示摘要的方法

<img src="http://www.williamlong.info/logo/wordpress.gif" alt="WordPress" class="thumb" /><p>  在WordPress系统中,默认的首页和目录页使用的书全文输出,这对于文章内容较长的博客来说很不方面,下面我介绍一个方法,可以简单的实现在WordPress首页和目录页显示摘要而非全文。</p><p>  首先找到wp-content/themes下你使用的模板目录,查找目录中的文件,如果有home.php则修改home.php,没有的话就修改index.php,找到&lt;?php the_content(); ?&gt;这一行,将其修改为以下代码:</p><p>&nbsp;&lt;?php if(is_category() || is_archive() || is_home() ) {<br />&nbsp;&nbsp;&nbsp;&nbsp; the_excerpt();<br />&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;&nbsp; the_content('Read the rest of this entry &amp;raquo;'); <br />&nbsp;} ?&gt;<br />&nbsp;&lt;div class=&quot;details&quot;&gt;&lt;div class=&quot;inside&quot;&gt;&lt;?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?&gt; so far | &lt;a href=http://www.williamlong.info/archives/&quot;&lt;?php the_permalink() ?&gt;&quot;&gt;Read On &amp;raquo;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</p><p>  这时,你的WordPress首页和分类就显示为摘要信息而不是全文信息了,演示界面请参见我的英文博客。</p><p>  这段代码可以在你的首页、存档页、目录页使用摘要输出,使用摘要输出后,整个WordPress的重复内容就少多了,很利于搜索引擎优化。</p><p>  英文版:WordPress Excerpt Seo Tips</p>
页: [1]
查看完整版本: 在WordPress首页和目录页显示摘要的方法
PageRank