Description 和 Keywords 的重要性已经不像以前那么重要了,但是设置正确的 Description 和 Keywords 还是对你的排名有利。
WordPress 在撰写日志的时候,可以给日志添加摘要(excerpt)和标签(tag),我的做法就是,就如给日志添加了摘要就把摘要做为 Description,如果没有设置摘要的话,则截取文章的前 220 个字作为 Description,而标签直接作为 Keywords。代码如下:
<?if (is_home()){ $description = "我爱水煮鱼是一个关注 WordPress 开源博客平台应用和互联网的 IT 博客。"; $keywords = "WordPress, 博客, 互联网, 主题, 插件"; } elseif (is_single()){ if ($post->post_excerpt) { $description = $post->post_excerpt; } else { $description = substr(strip_tags($post->post_content),0,220); } $keywords = ""; $tags = wp_get_post_tags($post->ID); foreach ($tags as $tag ) { $keywords = $keywords . $tag->name . ", "; } } ?> <meta name="keywords" content="<?=$keywords?>" /> <meta name="description" content="<?=$description?>" />
上面代码请放到 header.php 相应的位置,同样我也只优化了首页和日志页面。

Blinux | 2009-08-09 09:26:28 | #
现在侧边栏可以通过wp kit cn来实现了
http://www.blinux.cn/wp-kit-cn/
支持 反对
御用软件 | 2009-11-07 15:08:35 | #
恩,不错,按你的方法优化了下,谢谢了……
http://yyrj.org
可到这里查看效果
支持 反对
tooko | 2010-02-27 13:32:19 | #
逗号用什么,中文的逗号还是用英文的逗号?
支持 反对
Denis | 2010-02-28 19:21:23 | #
英文的!
支持 反对
oceanthink | 2010-03-25 10:40:13 | #
很好很强大,特来感谢,在你博客中看到很多我想去用代码实现可是还没有思路的东西,太喜欢了。
支持 反对