优选主流主机商
任何主机均需规范使用

如何利用日常习惯提升个人生产力与幸福感

直接上代码吧

代码如下:

<title><?php

if(is_category()){

single_cat_title();

}elseif(is_single() || is_page()){

single_post_title();

}elseif(is_search()){

echo wp_specialchars($s);

}else{

wp_title(”,true);

}

if(! is_home()){

echo ‘ – ‘;

}

?></title>

<?php

if(is_page()){

$description = mb_strimwidth(strip_tags(apply_filters(‘the_content’, $post->post_content)), 0, 200, ‘…’);

$keywords = $post->post_title;

}elseif(is_category()){

$description = trim(strip_tags(category_description($cat_ID)));

$keywords = single_cat_title(”, false);

}elseif(is_tag()){

$keywords = single_tag_title(”, false);

$description = trim(strip_tags(tag_description($tag_ID)));

}elseif(is_single()){

if($post->post_excerpt){

$description = $post->post_excerpt;

}else{

$description = mb_strimwidth(strip_tags(apply_filters(‘the_content’, $post->post_content)), 0, 200, ‘…’);

}

$keywords = $post->post_title;

}else{

$keywords = ‘PHP博客,PHP,MySQL,Linux,C,编程算法,网站架构,互联网’;

$description = ‘专注WEB开发,热爱PHP/MySQL/Linux/C/编程算法/网站架构,崇尚自由关注互联网’;

}

?>

<meta name=”keywords” content=”<?php echo $keywords; ?>” />

<meta name=”description” content=”<?php echo str_replace(PHP_EOL, ”, $description); ?>” />

未经允许不得转载:搬瓦工中文网 » 如何利用日常习惯提升个人生产力与幸福感