<?php if (is_single()){if($post->post_excerpt){$description=strip_tags($post->post_excerpt);}else{$description=substr(strip_tags($post->post_content),0,110);}$keywords=”;$tags=wp_get_post_tags($post->ID);foreach($tags as $tag){$keywords=$keywords.$tag->name.’, ‘;}}?>
$description = "【改为wordpress首页网站描述】";
$keywords = "【改为wordpress首页网站关键字】";
} elseif (is_single()){
$description = mb_strimwidth(strip_tags($post->post_content),0,400);//400才能自动截取200字左右作为文章描述,可按需修改
$keywords = "";
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag ) {
$keywords = $keywords . $tag->name . ",";
}
} elseif(is_category()){
$description = category_description();
}
?>