WP的keywords和description 优化方法

  看了水煮鱼的方法.他分别在2篇文章里边写给出了代码.

  这里我总结起来. 做个记号,方便以后使用~

<?if (is_home()){
    $description = "描述";
    $keywords = "关键字,关键字";
} elseif (is_single()){   
    if ($post-&gt;post_excerpt) {
        $description     = $post->post_excerpt;
    } else {
        $description = substr(strip_tags($post-&gt;post_content),0,220);
    }
    $keywords = "";       
    $tags = wp_get_post_tags($post-&gt;ID);
    foreach ($tags as $tag ) {
        $keywords = $keywords . $tag->name . ", ";
    }
} elseif(is_category()){
    $description     = category_description();
}
?>
<meta name="keywords" content="<=$keywords>" >
<meta name="description" content="<?=$description?>" />

  2篇文章的地址:   http://fairyfish.net/2007/09/11/wordpress-23-seo/   http://fairyfish.net/2008/11/16/wordpress-seo-2-description-keywords/