不使用wordpress插件添加页面关键词和描述信息
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>直接上代码吧</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<div style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div style="margin: 0px; padding: 0px; outline: none; float: right; line-height: 25.2px; font-size: 14px;">
<span style="line-height: 25.2px; cursor: pointer;"><u>复制代码</u></span>
</div>
代码如下:</div>
<div id="phpcode19" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
<title><?php<br>
if(is_category()){<br>
single_cat_title();<br>
}elseif(is_single() || is_page()){<br>
single_post_title();<br>
}elseif(is_search()){<br>
echo wp_specialchars($s);<br>
}else{<br>
wp_title('',true);<br>
}<br>
if(! is_home()){<br>
echo ' - ';<br>
}<br>
?></title><br>
<?php<br>
if(is_page()){<br>
$description = mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 200, '...');<br>
$keywords = $post->post_title; <br>
}elseif(is_category()){<br>
$description = trim(strip_tags(category_description($cat_ID)));<br>
$keywords = single_cat_title('', false); <br>
}elseif(is_tag()){<br>
$keywords = single_tag_title('', false); <br>
$description = trim(strip_tags(tag_description($tag_ID)));<br>
}elseif(is_single()){<br>
if($post->post_excerpt){<br>
$description = $post->post_excerpt; <br>
}else{<br>
$description = mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 200, '...'); <br>
}<br>
$keywords = $post->post_title; <br>
}else{<br>
$keywords = 'PHP博客,PHP,MySQL,Linux,C,编程算法,网站架构,互联网';<br>
$description = '专注WEB开发,热爱PHP/MySQL/Linux/C/编程算法/网站架构,崇尚自由关注互联网';<br>
}<br>
?><br>
<meta name="keywords" content="<?php echo $keywords; ?>" /><br>
<meta name="description" content="<?php echo str_replace(PHP_EOL, '', $description); ?>" /></div>
頁:
[1]