来自 水煮鱼 的代码:
<?if (is_home()){
$description = "谈谈网络,聊聊生活,记录生活。";
$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?>" />
标签:WordPress 分类:应用相关