<?php
if (is_home() || is_archive() || is_tag() ) { //判断页面属性主页、栏目页、标签页等
$description = "BLUEFATE博客,专注于SEO优化推广和网络营销策划";//修改为网站低?捐述
$keywords = "BLUEFATE,SEO博客,SEO优化,网络推广,网络营销策划";//改为网站设置的关键词
}
elseif (is_single()) //判断是否为内容页
{
if ($post->post_excerpt) {
$description = $post->post_excerpt;
} else {
$description = substr(strip_tags($post->post_content),0,220); //截取文排名蛋俣劝220字节作为描述
}
$keywords = "";
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag ) {
$keywords = $keywords . $tag->name . ", ";
}
}
?>
<meta name="keywords" content="<?=trim($keywords)?>" /> //trim函数过滤掉两头的空白
<meta name="description" content="<?=trim($description)?>" />
|