meta name 优化
Posted on | 十二月 17, 2009 | 1 Comment
Description 和 Keywords 的重要性已经不像以前那么重要了,但是设置正确的 Description 和 Keywords 还是对你的排名有利。
WordPress 在撰写日志的时候,可以给日志添加摘要(excerpt)和标签(tag),我的做法就是,就如给日志添加了摘要就把摘要做为 Description,如果没有设置摘要的话,则截取文章的前 220 个字作为 Description,而标签直接作为 Keywords。代码如下:
<?if (is_home()){
$description = “cq-cser是一个关注 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 相应的位置
ALL IN ONE SEO其实也不错
相关文章:
- 浅读”google-seo-report-card”:感想
- 10 tips to make more money fromWP
- 7 Must Have WordPress Plugins For Every Blog
- WordPress 永久链接以及在各种平台上的实现方法
- VPS 快速安装 Linux+Nginx+MySQL+PHP 环境【转】
评论|Comments
One Response to “meta name 优化”
留言|Leave a Reply
![如果您自认为是一位忠实的Silverlight-Fans,那么请将此标志放到您的博客中成为一名真正的[银光使者]](http://images.cnblogs.com/cnblogs_com/alamiye010/Silverlighter1.jpg)
十二月 17th, 2009 @ 23:42
http://cq-cser.cn