<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>李清海&#039;s blog &#187; SEO</title>
	<atom:link href="http://www.liqinghai.com/tag/seo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.liqinghai.com</link>
	<description>Just another wordpress weblog</description>
	<lastBuildDate>Tue, 08 Jun 2010 06:14:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type='text/javascript' src='http://www.liqinghai.com/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
	<item>
		<title>为WordPress添加keyword和description标签</title>
		<link>http://www.liqinghai.com/add-keyword-and-description-for-wordpress/</link>
		<comments>http://www.liqinghai.com/add-keyword-and-description-for-wordpress/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 05:58:29 +0000</pubDate>
		<dc:creator>grubylee</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.liqinghai.com/?p=240</guid>
		<description><![CDATA[刚刚查看我博客源代码的时候，发现没有keyword和description标签，而Google索引的首页描述，经常是我的第一篇文章的内容，并且没有关键字。而文章页面的快照是内容的前100字，也没有关键字。我没有安装SEO插件。还是觉得有必要进行优化下。 下面以我的英文博客Google Support Blog为例，给wordpress添加keyword和description属性。 首先找你主题文件夹里的header.php，部分主题可能是head.php 找到title属性，并在其后面添加如下代码： &#60;?php if &#40;is_home&#40;&#41;&#41;&#123; $description = &#34;Google Support Blog Focus on Google technology!&#34;; $keywords = &#34;Google Docs,Google Chrome,Chrome theme,Chrome plugin,Google Analystic&#34;; &#125; elseif &#40;is_single&#40;&#41;&#41;&#123; $description = substr&#40;strip_tags&#40;$post-&#62;post_content&#41;,0,220&#41;; $keywords = &#34;&#34;; $tags = wp_get_post_tags&#40;$post-&#62;ID&#41;; foreach &#40;$tags as $tag &#41; &#123; $keywords = $keywords . $tag-&#62;name . &#34;, &#34;; &#125; &#125; ?&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>刚刚查看我博客源代码的时候，发现没有keyword和description标签，而Google索引的首页描述，经常是我的第一篇文章的内容，并且没有关键字。而文章页面的快照是内容的前100字，也没有关键字。我没有安装SEO插件。还是觉得有必要进行优化下。</p>
<p>下面以我的英文博客<a href="http://googlesupport.org">Google Support Blog</a>为例，给wordpress添加keyword和description属性。</p>
<p>首先找你主题文件夹里的header.php，部分主题可能是head.php</p>
<p>找到title属性，并在其后面添加如下代码：</p>
<p><span id="more-240"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
    <span style="color: #000088;">$description</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Google Support Blog Focus on Google technology!&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$keywords</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Google Docs,Google Chrome,Chrome theme,Chrome plugin,Google Analystic&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span>is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>    
    <span style="color: #000088;">$description</span> <span style="color: #339933;">=</span>  <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">220</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$keywords</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>        
    <span style="color: #000088;">$tags</span> <span style="color: #339933;">=</span> wp_get_post_tags<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tag</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$keywords</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$keywords</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$tag</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;meta name=&quot;keywords&quot; content=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$keywords</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$description</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;</pre></div></div>

<p>那么google索引的首页描述应该为“Google Support Blog Focus on Google technology!”，首页关键字应该是“Google Docs,Google Chrome,Chrome theme,Chrome plugin,Google Analystic&#8221;。而单页面的话描述内容是文章的前200个字符。关键字则是文章的TAG。大家可以查看我的源文件看看效果。当然你也可以为标签，分类等页面添加keyword、description标签，方法类似啦</p>
<p>至于原理，我就不在这里卖弄了。注意使用的时候把描述和关键字替换成自己的。 <img src='http://www.liqinghai.com/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.liqinghai.com/add-keyword-and-description-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
