解决Google中的短的元说明问题
前几天开始试用Google Webmaster Tools,在里面总是看到“短的元说明”里面有几个文章在里面,搞不明白是什么意思,虽然Google Webmaster里面解释“短的元说明”不会影响搜索,不过看着它们存在着,并且不断增长的数量,总感觉不舒服。找了找资料看了一下,原来意思是说,在文章的Meta 说明里面Description这个说明文字短了,又找了点资料说,最好是在200-500字之间最好。
找来主题里面关于Meta Description这一行代码看了一下,
$description = $post->post_title;
难怪总是短呢,把title作description ,不短才怪呢!要是长了的话,文章的标题那就太奇怪了。OK,找到问题了,就好解决。
把$description = $post->post_title;替换成下面的代码试一下,
if ($post->post_excerpt) {
$description = $post->post_excerpt;
} else {
$description = substr(strip_tags($post->post_content),0,220);
}
$description = $post->post_excerpt;
} else {
$description = substr(strip_tags($post->post_content),0,220);
}
<meta name=”keywords” content=”<?php echo htmlspecialchars($post->post_excerpt, ENT_QUOTES); ?>” />
调整完,更新文件,打开文件,查看源代码,OK,长了。:)
发表评论
