wordpress中”head”的优化

05

Tags:     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之前就好了。

One Response to “ wordpress中”head”的优化 ”

  1. DaBai Says:

    同学,你放代码要放全,说明方法咧

    [回复]

Leave a Reply