![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
#1
IP: 112.87.85.4
|
|||
|
|||
|
一开始在写自定义主题时,没有写关键字和描述,结果wordpress本身也没带,导致谷歌收录时,所有的文章全都是一样的摘要,而且也很混乱。
令人非常意外,也不知道这是怎么个收录法,所以就想到了加关键字和描述,一是为了谷歌能够更好的收录,二是想更改现在谷歌收录的文章摘要,听说之前全是一样的摘要被谷歌看成是垃圾网站,然后就不怎么收录了。 然后我就想将页面的关键字和描述弄成这样的,首页有固定关键字和描述,文章页提取标签为关键字,excerpt为描述或者截取文章的前200多字为描述,其他的搜索页,标签页,分类页,存档页有固定关键字和提取他们页面的第一篇文章的excerpt为描述或者文章的前200多字为描述。 实现方法: 在主题的header.php文件中的</title>下面加入代码: <?php if(is_home()){ $description="网站首页描述"; $keywords="网站关键字"; ?> <?php }elseif(is_single()){ if($post->post_excerpt){ $description=$post->post_excerpt; }else{ $description=substr(strip_tags($post->post_content),0,250); } $keywords=""; $tags=wp_get_post_tags($post->ID); foreach($tags as $tag){ $keywords=$keywords.$tag->name.","; } ?> <?php }else{ $keywords="网站关键字"; $description=substr(strip_tags($post->post_content),0,220); } ?> <meta name="keywords" content="<?=$keywords?>" /> <meta name="description" content="<?=$description?>" /> 通过这样的更改,几天过后,谷歌的收录摘要就渐渐的更改过来了,也开始重新收录了。 |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple Steps to Change Your Table Prefix in WordPress | Abby | WordPress | 0 | 2014-04-14 03:40 PM |
| Install WordPress on IIS | topvip | Blog(博客)/Wiki(维客)/RSS/Cms | 1 | 2010-01-25 08:31 PM |
| 让wordpress首页显示特殊页面(flash首页等) | yahoo | Blog(博客)/Wiki(维客)/RSS/Cms | 0 | 2009-02-25 06:58 AM |
| wordpress 搜索引擎优化的二十条实用技巧 | car | 搜索引擎优化 | 0 | 2008-03-11 08:33 AM |
| WordPress 中文包 | sunshine | Blog(博客)/Wiki(维客)/RSS/Cms | 0 | 2007-03-12 10:16 AM |