wordpress中”head”的优化
二 05
Tags:wordpress 1 Comment »
最近查了下博客在google的收录情况,发现收录的所有页面的内容描述统统都是head里的description。在大白的帮助下,在head里加了个关键词和描述的判断。这样就可以随意修改了。贡献出代码来:请将全角的单书名号改为半角的
<?php
$keyContent = get_post_meta($post->ID, ‘keywords’, true);
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag ) {
$keywords = $keywords . $tag->name . “, “;
}
if($keyContent==”){$keyContent .= $keywords;}
$keyContent .= “,dabai,大白”;
if ( is_home() ) {
$keyContent=”hsiang,chieh,beautycss.org”;
}$desContent = get_post_meta($post->ID, ‘description’, true);
if ( is_home() ) {
$desContent=”this is the blog of hsiang chieh to description the web and life”;
}
elseif ( $desContent==” ) {
$desContent = substr(strip_tags($post->post_content),0,220);
}
?><meta name=”keywords” content=”” />
<meta name=”description” content=”” />
这段代码直接插在head的title之前就好了。

二月 5th, 2009 at 9:02 下午
同学,你放代码要放全,说明方法咧
[回复]