怎样添加wordpress的关键词和描述?

就是站长之家查得到你的网站关键词和描述。请问怎么设置?
需要具体过程,谢谢!!!!另外我用过插件All in One SEO Pack 的,不行。

如果你会写代码就方便,不会的话建议还是使用All in One SEO Pack插件,这样方便很多。

用插件应该不会像你说的那样不会显示,你直接用浏览器的源代码看看,或许你在站长工具那的缓存,所以没显示出来。

用代码的方法为:

把以下代码放header.php文件中的标题<title>之下。

<?php
if (is_home()) {
$keywords = $options['keywords'];
$description = $options['description'];
}elseif (is_single()) {
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag ) {$title_tags = $title_tags .$tag->name ."|"; $keywords = $keywords .$tag->name .",";}
$title_tags = substr($title_tags,0,-1);
if($title_tags) $title_tags = '|'.$title_tags;
$keywords = substr($keywords,0,-1);
if (has_excerpt()) {
$description = get_the_excerpt();
}else {
$description = mb_strimwidth(strip_tags(apply_filters('the_content',$post->post_content)),0,220,"...");
$description = str_replace("\n","",$description);
$description = empty($description)? $keywords : $description;
}
}elseif (is_category()) {
$keywords = single_cat_title("", false);
if ($paged > 1){
$description = trim(strip_tags(category_description($cat_ID))).' - '.get_bloginfo('name').'第'.$paged.'页。';
}else{
$description = trim(strip_tags(category_description($cat_ID)));
}
}elseif (is_page()) {
$keywords = get_the_title("", false);
$description = mb_strimwidth(strip_tags(apply_filters('the_content',$post->post_content)),0,220,"...");
}elseif (is_tag()) {
$keywords = single_tag_title("", false);
if ($paged > 1){
$description = trim(strip_tags(tag_description($tag_id))).' - '.get_bloginfo('name').'的'.single_tag_title('',false).'的标签存档文章-第'.$paged.'页。';
}else{
$description = trim(strip_tags(tag_description($tag_id))).' - '.get_bloginfo('name').'的'.single_tag_title('',false).'的标签存档文章。';
}
}elseif (is_day()) {
$keywords = get_the_time('Y年m月d日');
if ($paged > 1){
$description = get_bloginfo('name').get_the_time('Y年m月d日').'的存档文章-第'.$paged.'页。';
}else{
$description = get_bloginfo('name').get_the_time('Y年m月d日').'的存档文章。';
}
}elseif (is_month()) {
$keywords = get_the_time('Y年m月');
if ($paged > 1){
$description = get_bloginfo('name').get_the_time('Y年m月').'的存档文章-第'.$paged.'页。';
}else{
$description = get_bloginfo('name').get_the_time('Y年m月').'的存档文章。';
}
}elseif (is_year()) {
$keywords = get_the_time('Y年');
if ($paged > 1){
$description = get_bloginfo('name').get_the_time('Y年').'的存档文章-第'.$paged.'页。';
}else{
$description = get_bloginfo('name').get_the_time('Y年').'的存档文章。';
}
}elseif(is_search()) {
$keywords = $s;
$description = get_bloginfo('name').$s.'的搜索结果。';
}elseif(is_404()) {
$keywords = '404,错误页面';
$description = '404错误,未找到你需要的页面,请返回首页。';
}
?>

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-03-31
All in One SEO PackHome 中(Keywords (comma separated):这里是关键词) Home Description填写描述。追问

我填了的,但是不行啊,站长工具没显示啊??

本回答被网友采纳
第2个回答  2013-04-07
应该在自定义站点里面吧,我是下的一个插件弄得。我好像题不大意哦。
标题应含关键词,描述应含2次关键词,读起来通顺就好了,120字以内。
第3个回答  2013-04-03
用seo 插件
相似回答