WordPress SEO 终极教程
最近开博,沉迷于WordPress的SEO。网上有很多插件。All in one seo等等。可是插件过于耗费资源,况且我有点小小的完美主义。所以就准备自己修改代码来优化。
虽然偶也是搞技术出身,但是不写代码已经很多年。写代码进行WordPress SEO优化谈何容易,幸亏偶动手能力不错,再加上Google和网络上兄弟们的帮忙,耗费了一周的工作闲暇时候,经过上百次的修改和尝试,重于完成了这个艰巨的工作,以下代码Copy过去就可以用。不需要任何修改也不需要任何插件。
生成需要的变量
<?php
if (is_single()) {
$trimmed_title = wp_title(”, false);
$trimmed_title = trim($trimmed_title);
$title = $trimmed_title;
$keywords = “”;
$tags = wp_get_post_tags($post->ID);
foreach ($tags as $tag ) {
$keywords = $keywords . $tag->name . “|”;
}
$title = $title . “|” . $keywords;
}
?>
对于home category archive 使用 网站名|描述的方式来进行优化
<?php if ( is_home()) { ?><title><?php bloginfo (’description’); ?><?php echo (’|'); ?><?php bloginfo(’name’); ?></title><meta name=”description” content=”<?php bloginfo(’description’); ?>” /><?php } ?>
<?php if ( is_category()) { ?><title><?php single_cat_title(”); ?><?php echo (’|'); ?><?php bloginfo(’name’); ?></title><meta name=”description” content=”<?php echo wp_title(”,”); ?>” /><?php } ?>
<?php if ( is_archive()) { ?><title><?php bloginfo(’name’); ?><?php echo (’|'); ?><?php wp_title(”); ?><?php echo (’Archives’); ?></title>< content=”<?php echo wp_title(”,”); ?>” /><?php } ?>
对于Single页面和Page页面,使用 文章标题|Tags|网站名的方式进行优化 比如:IPD研发管理|集成产品开发|IPD|Abuer‘s blog
使用文章的摘要来填充Meta description。
<?php if ( is_single()) { ?><title><?php echo $title; ?><?php bloginfo(’name’); ?></title><meta name=”description” content=”<?php the_excerpt_rss(); ?>” /><?php } ?>
<?php if ( is_page()) { ?><title><?php bloginfo(’name’); ?><?php echo (’|'); ?><?php wp_title(”); ?></title><meta name=”description” content=”<?php the_excerpt_rss(); ?>” /><?php } ?>
禁止google 爬虫 抓取 single page home以外的网页,这是因为home,single, page 的内容和archive category里面的一样,这样会影响页面的PR。
<?php if (is_single() OR is_page() OR is_home()) : ?><meta name=”robots” content=”index,follow,noarchive”/><?php else : ?><meta name=”robots” content=”noindex,follow,noarchive” /><?php endif; ?>
<meta name=”googlebot” content=”noarchive” />
</head>
至于Keyword 我建议你用simple tag吧,主要原因是对Tag的管理很方便
就这么多,绝对比 ALL in One SEO 用的爽。
1月 8th, 2009 at 5:15 下午
八错,收藏了
[回复]
1月 10th, 2009 at 5:19 下午
晕,原本人家说ALLONE不好,准备放弃,现在看一下,不用也太麻烦了。何况不懂代码,改乱了就回不来了
[回复]
Abuer Reply:
1月 12th, 2009 at 11:52 上午
呵呵,也不算复杂,All in one Seo 是比较耗费资源
[回复]
1月 12th, 2009 at 1:36 下午
但我不懂代码,已经改了几个地方。
有一回改乱了,吓得我不轻。硬着头皮读代码,好像也不是很难。
只是WP的调用函数,不知道哪里有。
[回复]
Abuer Reply:
1月 12th, 2009 at 9:23 下午
呵呵,我的这部分代码是我自己Blog用的,WP的调用函数google一下就能够找到了。
[回复]
2月 27th, 2009 at 8:05 下午
淘宝导购购物网帮助你找到所需要的商品,为淘宝网上购物提供提供最有效的品质保障,所推介的淘宝商品已加入淘宝保障计划,让您享受网上购物的乐趣!
[回复]
3月 2nd, 2009 at 12:47 上午
爱情地图是阅读爱情小说,爱情故事,爱情短信,爱情日记,爱情测试,爱情电影的爱情网站,为你提供爱情小说,爱情故事,爱情短信,爱情日记,爱情测试,爱情电影等免费爱情文章
[回复]
5月 27th, 2009 at 9:21 上午
我很惊讶的。这是一件好事,我的研究。谢谢。 ^ _ ^
[回复]
5月 27th, 2009 at 9:35 上午
大文章!我爱您的网站;
[回复]
6月 12th, 2009 at 6:50 上午
Great article! I’m loving your website;
[回复]
6月 12th, 2009 at 8:43 上午
I am amazed with it. It is a good thing for my research. Thanks. ^_^
[回复]
6月 13th, 2009 at 8:02 上午
Hi, interest post. I’ll write you later about few questions!
[回复]
7月 7th, 2009 at 3:10 上午
It’s a masterpiece. I have never thought people can have such ideas and thoughts. You are great.
[回复]
7月 13th, 2009 at 3:09 上午
During the ahead week Big fellow divided the HouseGuests into four sets of three; Athletes, Populars, Brains, and Off-beats. A thirteenth HouseGuest goed to afford one set an drop settled the others.] Four HouseGuests from existence seasons returned to reinforcement one of each sets. Michael “Cowboy” Ellis of Big sibling 5 reinforcemented the Off-beats, Jessica Hughbanks of Big fellow 8 reinforcemented the Populars, Brian Hart of Big fellow 10 back uped the Brains, and Jessie Godderz also from Big fellow 10 faceed the Athletes. The set that won the premier crisis of Household, the Athletes, won Jessie Godderz to begin the of ill repute and appropriate for big brother 11 instances ly of their set. He also became the ahead prime minister of Household of the season.
[回复]
7月 13th, 2009 at 7:04 下午
We keep reading that he’s still dating Vanessa Hudgens, but who is zac efron dating the I just read that he’s dating Nikki Blonsky. clarify please?
[回复]
11月 16th, 2009 at 11:53 下午
i have been using Wordpress for 2 years but i still dont know how to do SEO using Wordpress, is there an SEO pluggin for Wordpress?.
[回复]
11月 20th, 2009 at 3:30 下午
值的学习
[回复]