间接上代码吧
<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); ?>" />
以上就是安达网络工作室关于《不使用wordpress插件添加页面关键词和描述信息》的一些看法。更多内容请查看本栏目更多内容!
get_search_form 函数在 WordPress 中是用来提取预设的搜寻表单或许默许的搜寻表单的。由于民间这个函数没有...
Wordpress 版本:3.3.1 一. 去掉 index.php 1. 编写404.php 文件,上传保留到博客根目录(和wordpress 的 in...
函数意义 wp_nav_menu () 自定义菜单显示函数 register_nav_menu () 自定义菜单注册函数 – 复数 register_...
一、评论提交超时: 大家可能会发现,在提交评论十分迟缓时最容易呈现“匿名”景象,这种状况次要...
WordPress的Ping List 能够经过后盾里的“设置(Option)”——“撰写(Writing)...
wpslugtranslate插件引见: 经过该插件,能够让wordpress中文博客的博主应用/%postname%.html方式的固定链接...