wordpres增加页面关键字和描述
在header.php文件中
//判断是否为主页
<?if (is_home()){
$description = “爱好者的博客”;
$keywords = “爱好、php博客”;
//判断一个单独一面是否被显示
} elseif (is_single()){
//判断发表日志时的摘要
if ($post->post_excerpt) {
$description = $post->post_excerpt;
} else {
//截取文章内容220字节
$description = substr(strip_tags($post->post_content),0,220);
}
//关键字就是文章的tags
$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?>” />
- JS实现ajax分页案例
- WordPress伪静态规则(IIS/Apache/Nginx各版本)与404页面