<?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>Think Again &#187; Tips</title>
	<atom:link href="http://www.thinkagain.cn/archives/tag/tips/feed" rel="self" type="application/rss+xml" />
	<link>http://www.thinkagain.cn</link>
	<description>Inspire thinking, inspire creativity, inspire future.</description>
	<lastBuildDate>Wed, 01 Feb 2012 07:31:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>12行代码给WordPress主题挂上AJAX</title>
		<link>http://www.thinkagain.cn/archives/1030.html</link>
		<comments>http://www.thinkagain.cn/archives/1030.html#comments</comments>
		<pubDate>Thu, 18 Dec 2008 16:20:27 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/?p=1030</guid>
		<description><![CDATA[最近，最新版的wordpress 2.7带来了全新的后台界面，加入了大量的特效，极为漂亮。并且也新增了不少特性，如评论分页和嵌套式回复。觉得有时间的话，是要考虑时下，与时俱进下，改进下Thin... ]]></description>
			<content:encoded><![CDATA[<p><img title="ajax" style="display: inline; margin: 0px 5px 5px 0px" alt="ajax" src="http://www.thinkagain.cn/wp-content/uploads/2008/12/ajax.jpg" align="left" /> 有段时间没有写些技术类的文章了，（p.s，似乎其它文章也没多写。。。）。先找几个借口搪塞下，比方说：</p>
<p>“最近比较忙”，呸，老套! <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_redface.gif' alt=':oops:' class='wp-smiley' />  </p>
<p>“最近没心情”，嗯，有点挂谱，  <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_confused.gif' alt=':???:' class='wp-smiley' />  </p>
<p>哎，找个理由其实也是蛮难的。看来，也得将嘴拙这列到缺点清单去了。</p>
<p>最近，最新版的wordpress 2.7带来了全新的后台界面，加入了大量的特效，极为漂亮。并且也新增了不少特性，如评论分页和嵌套式回复。觉得有时间的话，是要考虑时下，与时俱进下，改进下ThinkAgain的模板。另外，晚上和网友回mail的时候，看到他提及尝试给主题添加ajax评论等，看来ajax的应用似乎在wordpress越来越吃香了。咱也得跟上脚步，来写篇ajax相关文章。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' />  </p>
<p>什么是ajax？这问题问得多好哈。晕倒先。如果对该标题没有兴趣的童鞋可以就此打住不用看了。ajax全称为Asynchronous JavaScript and XML，是一种基于javascript的动态网页开发技术吧。可以说ajax技术的发展极大扩展了javascript的应用。简单地一句话概括，利用javascript将用户请求发送给服务器，服务器接收后处理请求并将结果反馈javascript，最后javascript将结果显示在网页上。原理知道后，可以得知了需要代码处理的也就是对应这么3个步骤了：</p>
<p>1. 如何利用javascript将数据提交给服务器？</p>
<p>2. 服务器如何处理请求？</p>
<p>3. 如何处理服务器的反馈。</p>
<p>貌似很复杂吗？又是javascript，又是服务器处理等等。其实不然啦，别忘了有很多高手早就给小白们开发了一大箩筐好东西了。比如，jquery。</p>
<p>什么是jquery？又来了，<a href="http://www.google.com/search?hl=en&amp;q=jquery" target="_blank">Google去吧</a>。jquery是个javascript库，其内置了非常强大且简单调用的ajax支持。这点是我们想使用的。而从2.3起，wordpress已经内置jquery了，只是在应用jquery上，在代码撰写上和原jquery略有不同而已，见文末补充资料2。</p>
<p>好了，既然wordpress已经内置jquery了，问题似乎很容易解决了。可以利用jquery来提交和处理ajax请求，用wordpress来搞定ajax请求。一切都是wordpress现成的，我们所做的只是如何<strong><u>合理地调用</u></strong>了。回顾下我们的口号，嘿嘿：</p>
<p>“没有蛀牙”。？？？有没有搞错？说起口号，顺口就喊上了，更正下，应该是：</p>
<p>“<strong><u>最大化利用Wordpress内置资源</u></strong>。”</p>
<p>废话一大堆，转入正题，12行代码就可以给主题挂上ajax？当然，没有搞错了，继续滚动鼠标往下看。<u><strong>这里假设，读者能简单修改php，且愿意动手测试（否则也很难体会其中乐趣了）</strong></u>。</p>
<p>先贴上代码。<u><strong>建议在本地服务器上测试</strong></u>。</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> &lt;?php wp_enqueue_script(<span style="color: #006080">'jquery'</span>);?&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> &lt;script type=<span style="color: #006080">'text/javascript'</span>&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> function my_ajax_example(){</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     jQuery.post(<span style="color: #006080">&quot;&lt;?php echo get_option('siteurl');?&gt;/wp-admin/admin-ajax.php&quot;</span>,</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     {action:<span style="color: #006080">&quot;my_ajax&quot;</span>},</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     function(str){jQuery(<span style="color: #006080">&quot;#ajaxtest&quot;</span>).append(str);});}</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> &lt;/script&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span> &lt;?php add_action(<span style="color: #006080">'wp_ajax_my_ajax'</span>, <span style="color: #006080">'my_ajax_example'</span>);?&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> &lt;?php    function my_ajax_example(){ ;?&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> &lt;?php    echo <span style="color: #006080">'&lt;b&gt;I LOVE WORDPRESS!!!&lt;/b&gt;'</span>;    ?&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> &lt;?php    exit;};?&gt;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span> &lt;input type=<span style="color: #006080">&quot;button&quot;</span> <span style="color: #0000ff">value</span>=<span style="color: #006080">&quot;My Ajax Example&quot;</span> onclick=<span style="color: #006080">&quot;my_ajax_example();&quot;</span>&gt;&lt;div id=<span style="color: #006080">&quot;ajaxtest&quot;</span>&gt;&lt;/div&gt;</pre>
</p></div>
</div>
<p><u>步骤1</u>：将第1-7行代码放到<u>header.php内&lt;/head&gt;</u>标签前面。用wp_enqueue_script来加载wp内置的jquery库，2-7行是加载测试用的js代码。其中调用jquery的post函数来发送ajax请求和接收反馈。</p>
<p><u>步骤2</u>：将第8-11行代码添加到<u>functions.php</u>里面。任意位置即可。但要注意不要出现语法错误。第8行将自定义函数my_ajax_example添加到wp的ajax api接口。9-11行定义了接收ajax请求后的处理和输出内容。这里比较简单，只是输出反馈给js这么一句发自内心的话：“<strong>I LOVE WORDPRESS!!!</strong>”。</p>
<p><u>步骤3</u>：将第12行代码添加到主题模板内拟显示ajax测试效果的地方。随便找个地方如single.php等添加进去。这行代码将会输出一个名为My Ajax Example的按钮，点击这个按钮后，即会发出一个ajax请求，然后显示ajax的反馈效果。这里是在按钮下面输出“<strong>I LOVE WORDPRESS!!!</strong>”。注意，用户应该要根据自己的需求，如ajax评论等，来修改接收ajax请求的函数内容。比如，ajax评论的话，这里就需要定义数据库全局变量$wpdb，然后添加其它语句用于将评论添加到数据库内。</p>
<p>通过这几行简单的代码，已经给wordpress主题挂上了Ajax。当然，这是个非常简单的，利用wordpress提供的api和内置的jquery进行ajax应用的例子。<strong><u>通过这个例子，主要是想提醒Developer们，可以利用wordpress提供ajax的api接口来添加ajax</u></strong>。至于其它应用么，那是<u><strong>**带进门，修行呢是要靠个人</strong></u>的。另外，ajax的应用，还有很多要注意，比如安全性等等。这些进门后，自己都要好好考虑的。换句话说，我还没认真考虑呢。p.s，注意利用wordpress的check_ajax_referer()。</p>
<p>上面的代码测试完毕了吧。嗯，似乎少了点什么？怎么没有骨碌碌转的东西，比如这个：</p>
<p><img title="loading" alt="loading" src="http://www.thinkagain.cn/wp-content/uploads/2008/12/loading.gif" /> </p>
<p>实现这个也很简单。多加2行代码即是了。</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> function my_ajax_example(){</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     jQuery(<span style="color: #006080">&quot;#ajaxtest&quot;</span>).append(<span style="color: #006080">'&lt;img src=&quot;http://www.thinkagain.cn/wp-content/uploads/2008/12/loading.gif&quot;/&gt;'</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     jQuery.post(<span style="color: #006080">&quot;&lt;?php echo get_option('siteurl');?&gt;/wp-admin/admin-ajax.php&quot;</span>,{action:<span style="color: #006080">&quot;my_ajax&quot;</span>},</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     function(str){</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     jQuery(<span style="color: #006080">&quot;#ajaxtest&quot;</span>).empty();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     jQuery(<span style="color: #006080">&quot;#ajaxtest&quot;</span>).append(str);});}</pre>
</div>
</div>
<p>注意，是添加了</p>
<p><strong>语句1，</strong>jQuery(&quot;#ajaxtest&quot;).append(&#8216;&lt;img src=&quot;http://www.thinkagain.cn/wp-content/uploads/2008/12/loading.gif&quot;/&gt;&#8217;);</p>
<p>即在显示内容前，显示该loading图片。建议将这个图片地址改为本地地址，这样加载速度会快些。以及</p>
<p><strong>语句2.</strong>jQuery(&quot;#ajaxtest&quot;).empty();</p>
<p>在显示内容前，将原内容清空。</p>
<p>p.s，加载内容前显示这种loading图片似乎是ajax的惯例了。处理方法也不单单是上面代码提到的这种，也可以利用jquery提供的其它ajax事件来激活。</p>
<p>&#160;</p>
<p><strong>补充资料，有兴趣延伸阅读下，（授之以渔）：</strong></p>
<p>1. WordPress ajax api接口</p>
<p>用文本编辑器打开wp-admin/admin-ajax.php文件，注意Line1040（2.7版）的这行代码：do_action( &#8216;wp_ajax_&#8217; . $_POST['action'] );</p>
<p>所以，上述代码中第5行，就是提交了一个action变量，其值为“myajax”；</p>
<p>2. wordpress中jquery的应用：</p>
<p>要注意，<u><strong>调用jquery是用jQuery代替$</strong></u>。</p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/1030.html#comments">评论35:</a></p><p><strong>35.</strong><i>2011.06.01.7:58.pm</i>.&nbsp;<a href="http://www.nianqing.info">NianQing</a>: AJAX是个好东西</p><p><strong>34.</strong><i>2010.04.10.5:28.pm</i>.&nbsp;<a href="http://diglife.info">Terry</a>: 唉，主题不支持ajax，装了@reply或者wp thread comments 都用不了，该怎么办呢~~</p><p><strong>33.</strong><i>2009.12.30.1:18.am</i>.&nbsp;<a href="http://imn.im">Nox</a>: 我还是实现不了这个功能。哭泣啊。。</p><p><strong>32.</strong><i>2009.12.19.4:32.am</i>.&nbsp;Charles: <a href="#comment-110208" rel="nofollow">@我被WordPress中的admin_ajax折腾着 | Jinwen Say </a>
有没有解决办法呀？</p><p><strong>31.</strong><i>2009.06.27.9:56.am</i>.&nbsp;<a href="http://digau.cn">bolo</a>: 好东西啊，学习了</p><p><strong>30.</strong><i>2009.06.19.4:32.pm</i>.&nbsp;<a href="http://nophoebe.cn">忘记月亮</a>: 收藏</p><p><strong>29.</strong><i>2009.05.30.10:25.am</i>.&nbsp;<a href="http://www.xingzou.org/">SMILE</a>: <a href="#comment-110172" rel="nofollow">@Jinwen </a>一样..</p><p><strong>28.</strong><i>2009.05.17.6:27.pm</i>.&nbsp;<a href="http://www.saywp.com/wordpress/how-using-admin-ajax.html">我被WordPress中的admin_ajax折腾着 | Jinwen Say</a>: [...] 最后我找到12行代码给Wordpress主题挂上AJAX这篇文章提及到这个admin_ajax_函数接口的简单例子，自己尝试再更改主题的ajax调用，结果就是成功了！但是……条件是在Firefox下，在IE下会输出一个，仅仅一个数值：“-1”。失败。。。 [...]</p><p><strong>27.</strong><i>2009.05.17.4:09.am</i>.&nbsp;<a href="http://www.saywp.com">Jinwen</a>: 我这天在试，你有没有发现代码的效果只在FF下有效？在IE下会输出一个“-1”，却得不到正确的值？有没有解决的办法？</p><p><strong>26.</strong><i>2009.04.10.9:45.am</i>.&nbsp;<a href="http://www.ttune.net.ru">小T</a>: 写得真不错，现在还用不上 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_wink.gif' alt=':wink:' class='wp-smiley' /> </p><p><strong>25.</strong><i>2009.03.24.11:21.am</i>.&nbsp;<a href="http://lostindream.com">lostindream</a>: 强悍，测试</p><p><strong>24.</strong><i>2009.02.19.9:20.pm</i>.&nbsp;<a href="http://www.showfom.com/">Showfom</a>: 2.7也能用的吧</p><p><strong>23.</strong><i>2009.02.17.9:12.am</i>.&nbsp;<a href="http://www.idoin.com">Idoin</a>: ajax不熟悉，不过看你的教程应该可以搞定，不错。</p><p><strong>22.</strong><i>2009.01.23.4:42.pm</i>.&nbsp;<a href="http://partof.cn">chommy</a>: 直接复制代码么，有什么语法要求呢。貌似我那里不成功。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_eek.gif' alt=':shock:' class='wp-smiley' /> </p><p><strong>21.</strong><i>2009.01.10.5:29.pm</i>.&nbsp;<a href="http://sink.net.ru/">二手科学家</a>: 感觉好复杂，还是先不要了，有你的回复插件就可以啦！</p><p><strong>20.</strong><i>2009.01.01.6:32.pm</i>.&nbsp;<a href="http://www.snowyy.com/">Snowyy</a>: 入门，嗯，适合我这般菜鸟，考完试再慢慢研究！谢谢你的教程！</p><p><strong>19.</strong><i>2009.01.01.3:34.pm</i>.&nbsp;<a href="http://www.coent.cn">Coent</a>: 没用过JQUERY,以后再研究</p><p><strong>18.</strong><i>2009.01.01.1:03.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-84506" rel="nofollow">@solincess </a>链接地址已经该啦。Happy New Year！ <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' /> </p><p><strong>17.</strong><i>2009.01.01.11:35.am</i>.&nbsp;<a href="http://www.thewonder.cn">solincess</a>: 你好，我是驴头狗尾的博主，现在原来的boryee.cn域名不用了，改用www.TheWonder.cn了，麻烦你改一下链接，谢啦。</p><p><strong>16.</strong><i>2008.12.29.7:35.pm</i>.&nbsp;<a href="http://cs72.com">kerby</a>: 我是来测试留言的 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_biggrin.gif' alt=':grin:' class='wp-smiley' /> </p><p><strong>15.</strong><i>2008.12.29.11:29.am</i>.&nbsp;<a href="http://www.panyuye.com">醉倚西风</a>: loading图片很好看</p><p><strong>14.</strong><i>2008.12.25.2:25.pm</i>.&nbsp;<a href="http://mlyang.cn">牧狼羊</a>: 呵呵，博主心情貌似不错，这篇日志写得很有调皮的味道啊。
圣诞快乐，哈哈</p><p><strong>13.</strong><i>2008.12.25.8:58.am</i>.&nbsp;<a href="http://booto.net">Kimcool</a>: Merry Christmas.</p><p><strong>12.</strong><i>2008.12.21.10:18.pm</i>.&nbsp;<a href="http://www.wodidai.com">花果山寨</a>: 这些技术性太强的我没有什么天赋去懂，只关注现成的活！</p><p><strong>11.</strong><i>2008.12.21.2:11.pm</i>.&nbsp;<a href="http://photozero.net/">neekey</a>: 了解了解～
不知道ThinkAgain最近有什么插件大作？</p><p><strong>10.</strong><i>2008.12.21.12:15.pm</i>.&nbsp;<a href="http://3284265.cn">shamas</a>: wordpress内置的东西太多了，　但用上了的又太少了</p><p><strong>9.</strong><i>2008.12.20.3:40.pm</i>.&nbsp;<a href="http://getfreeware.net">i.robot</a>: 其实早就想看看ajax和wordpress插件的东西,但是一直也是给自己找借口,哈哈,太懒了 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' /> </p><p><strong>8.</strong><i>2008.12.20.1:16.am</i>.&nbsp;<a href="http://www.linxo.cn">ZH CEXO</a>: 好玩的东西，先收着~</p><p><strong>7.</strong><i>2008.12.20.12:09.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-81412" rel="nofollow">@冰古 </a>这就是wordpress最吸引人的地方了。
<a href="#comment-81495" rel="nofollow">@i.robot </a>和<a href="#comment-81709" rel="nofollow">@辐射鱼 </a>这里只是抛砖引玉，真正的帅是要自己弄出来的。
<a href="#comment-81736" rel="nofollow">@MY-Hou </a>安全第一麽。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' />  
<a href="#comment-81750" rel="nofollow">@Yacca </a>想要上效果的话，好好利用wordpress内置的javascript库，如jquery和其插件dimension，UI等等。你的主题会变得很炫的。</p><p><strong>6.</strong><i>2008.12.20.12:02.am</i>.&nbsp;<a href="http://www.eemir3.com/">Yacca</a>: 不小心又一次抛砖引玉了 哈哈...ajax的确帅气,我宁可损失图片,也要上效果啊 哈哈</p><p><strong>5.</strong><i>2008.12.19.11:10.pm</i>.&nbsp;<a href="http://myhou.org">MY-Hou</a>: 一切...都先走本地  <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' /> </p><p><strong>4.</strong><i>2008.12.19.9:41.pm</i>.&nbsp;<a href="http://eachsite.org">辐射鱼</a>: 帅帅的特效</p><p><strong>3.</strong><i>2008.12.19.9:01.pm</i>.&nbsp;<a href="http://www.showfom.com/">Showfom</a>: 不错，支持个！</p><p><strong>2.</strong><i>2008.12.19.10:33.am</i>.&nbsp;<a href="http://getfreeware.net">i.robot</a>: 先收下了，有时间在仔细研究，嘿嘿</p><p><strong>1.</strong><i>2008.12.19.2:43.am</i>.&nbsp;<a href="http://bingu.net">冰古</a>: WordPress内置的函数功能太丰富了。</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.29.9:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/975.html" title="本文将继续来探讨Wordpress数据库查询的相关话题。文一里，我们知道了WP各">Wordpress数据库查询三板斧之三:如何查看WP数据库查询的具体内容 (7)</a></p><p><i>2008.07.28.10:25.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/974.html" title="网上很多都在谈如何关闭WP2.6的修订记录保存功能。想必已经有很多WP爱好">Wordpress Tips：如何使用自动保存的修订记录 (8)</a></p><p><i>2008.07.27.12:02.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/973.html" title="自2.5起，WP提供了在线编辑时的自动保存功能。自然也是有利有弊。弊么，">Wordpress Hacks：如何管理WP自动保存功能 (10)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2008.07.25.1:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/969.html" title="Updated: 2008-07-26，更新Hook代码。  续上文，通过Wordpress基准页面数据库查询">Wordpress数据库查询三板斧之二:如何减少WP数据库查询次数和提高运行效率 (12)</a></p><p><i>2008.07.20.8:12.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/966.html" title="看了下面这张抓图，你就知道我为什么要做这个统计了。  
   昨晚上在DH的">Wordpress数据库查询三板斧之一:WP基准页面数据库查询次数统计 (12)</a></p><p><i>2008.07.16.12:15.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/954.html" title="升级至2.6后，除了插件管理页的布局更改外，似乎还没注意到其它显著的变">启用WP2.6 Turbo功能Step by Step (10)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/1030.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/1030.html/feed</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>WordPress Hacks:WP2.2版后中文邮件标题乱码解决方法</title>
		<link>http://www.thinkagain.cn/archives/994.html</link>
		<comments>http://www.thinkagain.cn/archives/994.html#comments</comments>
		<pubDate>Tue, 09 Sep 2008 12:58:14 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/?p=994</guid>
		<description><![CDATA[今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程序下载了。照例是修改几处源代码以及将akismet删掉。然后上传升级。一切都很顺利。从更新上看，似乎2.6.2没有多大... ]]></description>
			<content:encoded><![CDATA[<p>今天，Wordpress官方发布了2.6.2版。没有跑去<a href="http://trac.wordpress.org/browser" target="_blank">Trac</a>看代码变动地方，直接就将程序下载了。照例是修改几处源代码以及将akismet删掉。然后上传升级。一切都很顺利。从更新上看，似乎2.6.2没有多大变化，运行upgrade.php，并未提示更新数据库。看来此版本的升级无涉及数据库方面的更改。</p>
<p><!--myadsense--></p>
<p>在朋友站点逛了圈，发现还是有很多WP站点发送的中文邮件标题容易出现乱码情况。索性将其解决方法放上来。此方法从2.2起至当前的2.6.2均有效。建议网友根据文中代码，自行修改源代码。</p>
</p>
<p>具体做法：</p>
<p>用文本编辑器打开wp-includes/class-phpmailer.php，在EncodeHeader函数内找到下列代码，大概在1165-1175行左右。</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">if</span> (strlen($str)/3 &lt; $x) {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     $encoding = <span style="color: #006080">'B'</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     $encoded = base64_encode($str);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     $maxlen -= $maxlen % 4;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     $encoded = trim(chunk_split($encoded, $maxlen, <span style="color: #006080">&quot;\n&quot;</span>));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> } <span style="color: #0000ff">else</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     $encoding = <span style="color: #006080">'Q'</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     $encoded = $<span style="color: #0000ff">this</span>-&gt;EncodeQ($str, $position);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>     $encoded = $<span style="color: #0000ff">this</span>-&gt;WrapText($encoded, $maxlen, <span style="color: #0000ff">true</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     $encoded = str_replace(<span style="color: #006080">&quot;=&quot;</span>.$<span style="color: #0000ff">this</span>-&gt;LE, <span style="color: #006080">&quot;\n&quot;</span>, trim($encoded));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> }</pre>
</div>
</div>
<p>将上述中的第4，5和9行前面加上注释符号&quot;//&quot;，使之失效。如下：</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">if</span> (strlen($str)/3 &lt; $x) {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     $encoding = <span style="color: #006080">'B'</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     $encoded = base64_encode($str);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #008000">//$maxlen -= $maxlen % 4;</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     <span style="color: #008000">//$encoded = trim(chunk_split($encoded, $maxlen, &quot;\n&quot;));</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> } <span style="color: #0000ff">else</span> {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     $encoding = <span style="color: #006080">'Q'</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     $encoded = $<span style="color: #0000ff">this</span>-&gt;EncodeQ($str, $position);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>     <span style="color: #008000">//$encoded = $this-&gt;WrapText($encoded, $maxlen, true);</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     $encoded = str_replace(<span style="color: #006080">&quot;=&quot;</span>.$<span style="color: #0000ff">this</span>-&gt;LE, <span style="color: #006080">&quot;\n&quot;</span>, trim($encoded));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> }</pre>
</div>
</div>
<p>保存退出，将修改后的class-phpmailer.php文件上传到服务器上。</p>
<p><strong>注：</strong>此法并不是我原创，乃是N久前在网上搜索到的。原出处也已忘记，故无法在此将出处标出。敬请见谅。</p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/994.html#comments">评论22:</a></p><p><strong>22.</strong><i>2008.09.15.10:53.pm</i>.&nbsp;<a href="http://www.snowyy.com/">不常识</a>: 当时请教过很多人，都被诊断为绝症了。但从朋友知他有经验，为了以前的文章也要付了……</p><p><strong>21.</strong><i>2008.09.13.7:57.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-71802" rel="nofollow">@不常识 </a>嗯，200元买的药方。只能说对方太恶心了，基于一个开源平台的Wordpress，解决一个小问题还要收费，个人比较不大喜好这种做法。</p><p><strong>20.</strong><i>2008.09.13.7:48.pm</i>.&nbsp;<a href="http://www.snowyy.com/">不常识</a>: 乱码问题我今年初遇过，花了200元买的药方啊~~~</p><p><strong>19.</strong><i>2008.09.13.12:07.am</i>.&nbsp;<a href="http://www.hypfx.com">流星</a>: 据在我博客上回复的beach指出，说是2.6.2已经改进了这个问题了……但是我确实修改时候没看到那个注释……</p><p><strong>18.</strong><i>2008.09.12.8:38.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-71687" rel="nofollow">@HE Yi </a>这个这个，需要澄清下，不是我原创的。</p><p><strong>17.</strong><i>2008.09.12.7:54.pm</i>.&nbsp;<a href="http://heyi.name">HE Yi</a>: 原创万岁！创新万岁！ <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_cool.gif' alt=':cool:' class='wp-smiley' /> </p><p><strong>16.</strong><i>2008.09.12.3:40.pm</i>.&nbsp;<a href="http://smartr.cn">Jinwen</a>: 自己懒着，不更新了。</p><p><strong>15.</strong><i>2008.09.11.7:24.pm</i>.&nbsp;<a href="http://www.cnpabi.com">pabi</a>: THX,DUDE</p><p><strong>14.</strong><i>2008.09.11.3:43.pm</i>.&nbsp;<a href="http://www.wodidai.com">花果山寨</a>: 谢谢提醒，马上更正！</p><p><strong>13.</strong><i>2008.09.10.8:33.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-71528" rel="nofollow">@流星 </a>意识形态挂帅的话，容易把自己弄得很累吧。</p><p><strong>12.</strong><i>2008.09.10.1:43.pm</i>.&nbsp;<a href="http://www.hypfx.com">流星</a>: 真赞，霏凡想去搞一个notepad++看看，结果所有下载都没有文件，而后忽然想起这作者当初在软件上说过支持zd的话，不会就此被霏凡给去除下载了吧……很寒
不过还是觉得ue其实挺方便
不过平时纯粹写txt时候，还是习惯用notexpad，虽然是2004年版本再也未更新，可是还是满好用</p><p><strong>11.</strong><i>2008.09.10.1:14.pm</i>.&nbsp;<a href="http://sink.net.ru/">二手科学家</a>: 没有更新，好像主要是安全性提高
等等2.7吧！</p><p><strong>10.</strong><i>2008.09.10.11:45.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-71523" rel="nofollow">@流星 </a>我一般用notepad++来编辑代码。这个小软件功能也很强大，且是免费的。</p><p><strong>9.</strong><i>2008.09.10.11:39.am</i>.&nbsp;<a href="http://www.hypfx.com">流星</a>: 我改了
发现你用的不是ue，其实我还是觉得ue方便点，行号真好找。
我把你这个转载到我博客了，修改了下，配了我的截图，留下了你的链接，呵呵</p><p><strong>8.</strong><i>2008.09.10.9:42.am</i>.&nbsp;<a href="http://pejag.cn">打篮球的手</a>: 还好没有发现乱码</p><p><strong>7.</strong><i>2008.09.09.10:51.pm</i>.&nbsp;<a href="http://www.wodidai.com">花果山寨</a>: 好了，又是一个解决的方法！3Q</p><p><strong>6.</strong><i>2008.09.09.10:42.pm</i>.&nbsp;<a href="http://www.linxo.cn/blog">ZH CEXO</a>: 刚升级来着，不明白~</p><p><strong>5.</strong><i>2008.09.09.9:57.pm</i>.&nbsp;<a href="http://www.charlestang.cn">Charles</a>: 原来如此，回头我试试</p><p><strong>4.</strong><i>2008.09.09.9:57.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-71482" rel="nofollow">@arthack </a>并不是所有中文标题都会出现乱码情况，时有时无的。具体造成的原因，我还不是很清楚，应该是和字符长度等有关系。</p><p><strong>3.</strong><i>2008.09.09.9:42.pm</i>.&nbsp;<a href="http://www.eemir3.com">Yacca</a>: 反正就12个文件么...我毅然升级掉了...</p><p><strong>2.</strong><i>2008.09.09.9:41.pm</i>.&nbsp;<a href="http://www.arthack.org">arthack</a>: 乱码我好像没有发现哦</p><p><strong>1.</strong><i>2008.09.09.9:35.pm</i>.&nbsp;<a href="http://genmicha.cn">Chada</a>: 沙发之，我还没升级到.2，懒得去升了，反正没多大变化。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' /> </p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2007.12.08.10:50.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/888.html" title="2007-12-09：注，我已经写了一个插件用于含有nextpage或more标签的feed全文输出">如何使用Wordpress内置的分页（Nextpage）功能？ (52)</a></p><p><i>2007.10.31.12:42.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/830.html" title="Updated:此问题已经在2.3.3中被修复。
*****************************
前几天，将Wordp">Wordpress Hacks:升级2.3.1可能出现邮件提醒失效的解决方法 (20)</a></p><p><i>2007.10.22.11:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/822.html" title="在wordpress中，默认点击评论者的链接时，会在同一窗口内打开该链接。这在">Wordpress Hacks: 在新窗口中打开评论者链接和no follow属性 (16)</a></p><p><i>2007.09.15.10:41.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/721.html" title="继将CSS修改符合W3C规范后，今天花了点时间，也将模板代码修改完毕，通过">继续修改模板 (4)</a></p><p><i>2007.08.21.8:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/611.html" title="又是一时心血来潮，试用过Wordpress后，想装上Movable Type 4.0玩玩看。于是就">图文介绍如何在本地服务器安装Movable Type 4.0 (15)</a></p><p><i>2007.06.11.3:55.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/189.html" title="由于博客上的图片大部分都是放在Flickr上的，所以Flickr被禁后导致国内朋友">WordPress解决Flickr图片显示方法 (3)</a></p><p><i>2007.04.30.8:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/161.html" title="Widgets是一个可视化Wordpress主题侧边栏编辑插件，用户可以在Wordpress后台主">如何修改代码使主题支持widgets (5)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/994.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/994.html/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>WordPress数据库查询三板斧之三:如何查看WP数据库查询的具体内容</title>
		<link>http://www.thinkagain.cn/archives/975.html</link>
		<comments>http://www.thinkagain.cn/archives/975.html#comments</comments>
		<pubDate>Tue, 29 Jul 2008 12:42:27 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[查询]]></category>
		<category><![CDATA[次数]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/archives/975.html</guid>
		<description><![CDATA[本文将继续来探讨Wordpress数据库查询的相关话题。文一里，我们知道了WP各个基准页面所需的数据库查询量。文二中，我介绍了利用WP自带技术实现降低数据库查询或读取次数的方法，将此法应... ]]></description>
			<content:encoded><![CDATA[<p>本文将继续来探讨Wordpress数据库查询的相关话题。<a href="http://www.thinkagain.cn/archives/966.html" target="_blank">文一</a>里，我们知道了WP各个基准页面所需的数据库查询量。<a href="http://www.thinkagain.cn/archives/969.html" target="_blank">文二</a>中，我介绍了利用WP自带技术实现降低数据库查询或读取次数的方法，将此法应用于模板中，可在不影响互动前提下，降低模板的数据库查询次数。如果您想了解下到底是那些函数或插件在消耗这些数据库查询呢？以及每个查询WP都从数据库中读什么东东呢？本文将帮您揭开这些问题的谜底。</p>
<p>照旧，一切都是利用WP自带技术的。继续拿起铲子，深挖WORDPRESS。</p>
</p>
<p>首先，先用文本编辑器打开wp-config.php，加入如下代码：</p>
<blockquote><p>define(&#8216;SAVEQUERIES&#8217;, <span style="color: #0000ff">true</span>);</p></blockquote>
<p>此行代码，将激活定义WP把每次数据查询的信息保存到数组内。然后用下述代码将数组内的各次数据库查询的信息显示出来，具体内容有三项：各次数据库查询的SQL代码，读取所消耗时间和执行数据库查询的函数名称。</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">if</span> (is_user_logged_in()){</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>     <span style="color: #0000ff">global</span> $wpdb;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     echo <span style="color: #006080">&quot;&lt;pre&gt;&quot;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     print_r($wpdb-&gt;queries);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     echo <span style="color: #006080">&quot;&lt;/pre&gt;&quot;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> }</pre>
</p></div>
</div>
<p>来看看上面这6行代码，第1和6行代码用于判断当前用户是否是注册用户，如果您愿意让普通浏览者看见这些分析结果，可以将这2行代码去掉。第2行，定义全局变量$wpdb，这是WP默认的数据库类。第3和5行，定义将分析结果嵌套在HTML&lt;pre&gt;标签内。第4行将输出各次数据库查询的信息，print_r()是php的输出变量信息的函数。</p>
<p>将上述6行代码放置到默认模板或其它模板的footer.php的&lt;/body&gt;标签前。打开页面，在页面的底部将会输出下列信息。注：如果有判断是否注册用户的代码，则必须是注册用户才能看到该信息。</p>
<p>如下例中，从0到8，共有9个数组，代表该页面总共发生了9次数据查询。每个数组里面包含3组信息，[0]为数据库查询所用的SQL代码，[1]查询所消耗的时间，基本上少都很少。Mysql效率还是非常高的。[2]为执行该次数据库查询的函数名称。</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">Array</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     [0] =&gt; <span style="color: #0000ff">Array</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>         (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>             [0] =&gt; <span style="color: #0000ff">SELECT</span> option_value <span style="color: #0000ff">FROM</span> leo_options <span style="color: #0000ff">WHERE</span> option_name = <span style="color: #006080">'siteurl'</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>             [1] =&gt; 0.00159311294556</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>             [2] =&gt; is_blog_installed</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         )</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     [1] =&gt; <span style="color: #0000ff">Array</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>         (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>             [0] =&gt; <span style="color: #0000ff">SELECT</span> option_name, option_value <span style="color: #0000ff">FROM</span> leo_options <span style="color: #0000ff">WHERE</span> autoload = <span style="color: #006080">'yes'</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>             [1] =&gt; 0.00426483154297</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>             [2] =&gt; wp_load_alloptions</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>         )</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>     [2] =&gt; <span style="color: #0000ff">Array</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>             [0] =&gt; <span style="color: #0000ff">SELECT</span> <span style="color: #0000ff">DISTINCT</span> id <span style="color: #0000ff">FROM</span> leo_wsdl_downloads <span style="color: #0000ff">WHERE</span> status = <span style="color: #006080">'1'</span> <span style="color: #0000ff">ORDER</span> <span style="color: #0000ff">BY</span> id <span style="color: #0000ff">ASC</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>             [1] =&gt; 0.00153589248657</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>             [2] =&gt; filetextInsert</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>         )</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>     [3] =&gt; <span style="color: #0000ff">Array</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>         (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>             [0] =&gt; <span style="color: #0000ff">SELECT</span> ID, post_name, post_parent <span style="color: #0000ff">FROM</span> leo_posts <span style="color: #0000ff">WHERE</span> post_name = <span style="color: #006080">'aboutme'</span> <span style="color: #0000ff">AND</span> (post_type = <span style="color: #006080">'page'</span> <span style="color: #0000ff">OR</span> post_type = <span style="color: #006080">'attachment'</span>)</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>             [1] =&gt; 0.00170397758484</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>             [2] =&gt; get_page_by_path</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>         )</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>     [4] =&gt; <span style="color: #0000ff">Array</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>         (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  33:</span>             [0] =&gt; <span style="color: #0000ff">SELECT</span> * <span style="color: #0000ff">FROM</span> leo_posts <span style="color: #0000ff">WHERE</span> ID = 2 <span style="color: #0000ff">LIMIT</span> 1</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  34:</span>             [1] =&gt; 0.00132393836975</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  35:</span>             [2] =&gt; get_post</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  36:</span>         )</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  37:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  38:</span>     [5] =&gt; <span style="color: #0000ff">Array</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  39:</span>         (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  40:</span>             [0] =&gt; <span style="color: #0000ff">SELECT</span> option_value <span style="color: #0000ff">FROM</span> leo_options <span style="color: #0000ff">WHERE</span> option_name = <span style="color: #006080">'page_for_posts'</span> <span style="color: #0000ff">LIMIT</span> 1</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  41:</span>             [1] =&gt; 0.000607967376709</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  42:</span>             [2] =&gt; get_option</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  43:</span>         )</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  44:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  45:</span>     [6] =&gt; <span style="color: #0000ff">Array</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  46:</span>         (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  47:</span>             [0] =&gt;  <span style="color: #0000ff">SELECT</span>   leo_posts.* <span style="color: #0000ff">FROM</span> leo_posts  <span style="color: #0000ff">WHERE</span> 1=1  <span style="color: #0000ff">AND</span> (leo_posts.ID = <span style="color: #006080">'2'</span>) <span style="color: #0000ff">AND</span> leo_posts.post_type = <span style="color: #006080">'page'</span>  <span style="color: #0000ff">ORDER</span> <span style="color: #0000ff">BY</span> leo_posts.post_date <span style="color: #0000ff">DESC</span> </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  48:</span>             [1] =&gt; 0.000730991363525</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  49:</span>             [2] =&gt; get_posts</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  50:</span>         )</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  51:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  52:</span>     [7] =&gt; <span style="color: #0000ff">Array</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  53:</span>         (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  54:</span>             [0] =&gt; <span style="color: #0000ff">SELECT</span> t.*, tt.*, tr.object_id <span style="color: #0000ff">FROM</span> leo_terms <span style="color: #0000ff">AS</span> t <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> leo_term_taxonomy <span style="color: #0000ff">AS</span> tt <span style="color: #0000ff">ON</span> tt.term_id = t.term_id <span style="color: #0000ff">INNER</span> <span style="color: #0000ff">JOIN</span> leo_term_relationships <span style="color: #0000ff">AS</span> tr <span style="color: #0000ff">ON</span> tr.term_taxonomy_id = tt.term_taxonomy_id <span style="color: #0000ff">WHERE</span> tt.taxonomy <span style="color: #0000ff">IN</span> (<span style="color: #006080">'category'</span>, <span style="color: #006080">'post_tag'</span>) <span style="color: #0000ff">AND</span> tr.object_id <span style="color: #0000ff">IN</span> (2) <span style="color: #0000ff">ORDER</span> <span style="color: #0000ff">BY</span> t.name <span style="color: #0000ff">ASC</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  55:</span>             [1] =&gt; 0.00423097610474</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  56:</span>             [2] =&gt; wp_get_object_terms</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  57:</span>         )</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  58:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  59:</span>     [8] =&gt; <span style="color: #0000ff">Array</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  60:</span>         (</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  61:</span>             [0] =&gt; <span style="color: #0000ff">SELECT</span> post_id, meta_key, meta_value <span style="color: #0000ff">FROM</span> leo_postmeta <span style="color: #0000ff">WHERE</span> post_id <span style="color: #0000ff">IN</span> (2) <span style="color: #0000ff">ORDER</span> <span style="color: #0000ff">BY</span> post_id, meta_key</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  62:</span>             [1] =&gt; 0.0023729801178</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  63:</span>             [2] =&gt; update_postmeta_cache</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  64:</span>         )</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  65:</span>&#160; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  66:</span> )</pre>
</p></div>
</div>
<p>通过此信息，我们可以清楚地看到在打开该页面时，是那些WP内置函数或插件函数要求读取数据库。如上例中的，第3次数据查询是由filetextInsert函数造成的，这个是一个插件函数。分析下数据查询1和2，对应为Array[0]和Array[1]，很显然，第1次查询是用于判断siteurl是否被赋值，siteurl值是存储在options表里面的。而第2次查询，是将options表里面所有autoload值为真的数据全部加载到内存中。<a href="http://www.thinkagain.cn/archives/969.html" target="_blank">文二</a>中的Idea就是基于此数据查询的。注意下，在此有点不大理解，既然第2次查询是加载options表的数据，那么请问，如果将此数据查询放在第1，这样的话siteurl也已经被加载了，只需从内存中读取siteurl值就可以了，就没有必要再去读取options表内的siteurl的值了。简单地调换下次序，再修改下代码，这不就可以减少一次数据查询了。所以说，WP有时候是有点莫名其妙。p.s，is_blog_installed是在WP加载widget时候被调用的。</p>
<p>此文会数据库查询分析之三板斧的最后一篇。写这几篇文章的主要目的在于<strong>分享</strong>和<strong>探讨</strong>。通过这三篇文章，相信能对您了解Wordpress数据库查询的来龙去脉有所帮助。文二的方法主要用来减少模板的数据库查询，其idea也可以用在插件的制作上。通过本文，可以来判断那些插件的调用需要数据库查询，然后再结合其作用，综合判断是否需要该插件。通过此法，我将现有模板首页的查询次数，从<strong>36</strong>次降到<strong>16</strong>次。虽说每次数据库查询视SQL语句和数据量大小而定，消耗的时间并不多，如上例中，一般都在0.00几秒。但这个数值是在本地服务器上的测试结果，而放置到网站上的测试，您会发现加载同样的页面，消耗的时间不尽相同，有的时候，单个查询甚至会需要1秒以上，其原因是当时数据库的负载（同时请求数，连接数等）高造成的。撇开静态化完全不需要数据库查询不提，减低数据库查询以及精简php代码解析，是能有效提高WP的运行效率方法之一。当然，找个更Powerful的服务器是最快也最直接有效的方法。嘿嘿，不过这也就少了分析的乐趣了。</p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/975.html#comments">评论7:</a></p><p><strong>7.</strong><i>2010.11.20.2:04.pm</i>.&nbsp;<a href="http://www.ylsnuha.com/reduce-queries/">如何查看WordPress数据库查询的具体内容:减小数据库查询次数 &#171; Some Dream</a>: [...] 为了减少数据库查询次数首先，先用文本编辑器打开wp-config.php，加入如下代码：  define(‘SAVEQUERIES’, true); [...]</p><p><strong>6.</strong><i>2008.11.08.9:31.pm</i>.&nbsp;<a href="http://www.9usb.net">网络漂流瓶</a>: 对于优化Wordpress的博客很有用。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_rolleyes.gif' alt=':roll:' class='wp-smiley' /> </p><p><strong>5.</strong><i>2008.08.07.10:02.am</i>.&nbsp;<a href="http://www.flywud.com">oyster</a>: 呵呵 可以继续发掘~~~</p><p><strong>4.</strong><i>2008.08.01.9:45.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @oyster: 应该要纠正下我的说法，wp是否自带缓存机制。其正确的说法应该是在早些版本，如2.3前，wp是有内置object cache缓存机制的，但是不知为何在新版中被取消了。现在来回答你的问题，wp是针对每个浏览者的动作，如打开页面等，作出相应的反馈的。所以，每次加载网页，那些查询等是会被执行的，并不是a打开页面加载了数据，b打开类似页面就不用加载数据了，如果是这样的话，那就是缓存了。而实际上并非如此的。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p><p><strong>3.</strong><i>2008.07.31.9:53.pm</i>.&nbsp;<a href="http://www.flywud.com">oyster</a>: 第1次查询是用于判断siteurl是否被赋值，siteurl值是存储在options表里面的。而第2次查询，是将options表里面所有autoload值为真的数据全部加载到内存中。

 你这里也说到了 会把options里的数据存储到内存的siteurl里.
应该说第一个人打开了这个网页 那么这个网页的大部分数据都已经被存储到内存中,第二个人来访问的话 就直接读取内存的数据了.这就是缓存机制啦.

不过我只是猜想而已,因为我才学 php,和接触wp 两个月 .呵呵 

实在不敢乱吹~~~</p><p><strong>2.</strong><i>2008.07.29.10:25.pm</i>.&nbsp;<a href="http://zohua.cn">Zohua</a>: 搞不懂啊  学习</p><p><strong>1.</strong><i>2008.07.29.9:59.pm</i>.&nbsp;<a href="http://www.lidiy.com">lidiy</a>: 这个专业~~ 有帮助~</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.07.25.1:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/969.html" title="Updated: 2008-07-26，更新Hook代码。  续上文，通过Wordpress基准页面数据库查询">Wordpress数据库查询三板斧之二:如何减少WP数据库查询次数和提高运行效率 (12)</a></p><p><i>2008.07.20.8:12.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/966.html" title="看了下面这张抓图，你就知道我为什么要做这个统计了。  
   昨晚上在DH的">Wordpress数据库查询三板斧之一:WP基准页面数据库查询次数统计 (12)</a></p><p><i>2008.12.19.12:20.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/1030.html" title=" 有段时间没有写些技术类的文章了，（p.s，似乎其它文章也没多写。。。">12行代码给Wordpress主题挂上AJAX (35)</a></p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.28.10:25.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/974.html" title="网上很多都在谈如何关闭WP2.6的修订记录保存功能。想必已经有很多WP爱好">Wordpress Tips：如何使用自动保存的修订记录 (8)</a></p><p><i>2008.07.27.12:02.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/973.html" title="自2.5起，WP提供了在线编辑时的自动保存功能。自然也是有利有弊。弊么，">Wordpress Hacks：如何管理WP自动保存功能 (10)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2008.07.16.12:15.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/954.html" title="升级至2.6后，除了插件管理页的布局更改外，似乎还没注意到其它显著的变">启用WP2.6 Turbo功能Step by Step (10)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/975.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/975.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>WordPress Tips：如何使用自动保存的修订记录</title>
		<link>http://www.thinkagain.cn/archives/974.html</link>
		<comments>http://www.thinkagain.cn/archives/974.html#comments</comments>
		<pubDate>Mon, 28 Jul 2008 14:11:20 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/?p=974</guid>
		<description><![CDATA[网上很多都在谈如何关闭WP2.6的自动修订记录保存功能。想必已经有很多WP爱好者已经在wp-config.php里面通过设定'WP_POST_REVISIONS'=false，将这个功能给K了吧。我呢，偏偏来凑热闹，谈谈如何使用这... ]]></description>
			<content:encoded><![CDATA[<p>网上很多都在谈如何关闭WP2.6的修订记录保存功能。想必已经有很多WP爱好者已经在wp-config.php里面通过设定&#8217;WP_POST_REVISIONS&#8217;=false，将这个功能给K了吧。我呢，偏偏来凑热闹，谈谈如何使用这个修订记录(post revision)保存功能。嗯，按下SAVE按钮来，先保存下。</p>
</p>
<p>先别急，写到这里再来保存一下，回头抓图写文章才有依据啊。</p>
<p>好了，按了2次SAVE，现在应该有2个修订版本了吧。到下面的Post revisions看看，抓个图放上来。</p>
<p><a class="thickbox" title="修订记录次数查看" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/post_revision_1.jpg" target="_blank"><img alt="post revision history" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/post_revision_1.jpg" /></a></p>
<p>看见不，在页面内容编辑区下部的post revisions处，已经有2个修订记录。不凑巧，时间间隔太短了，嘿，我打字太快了。呵呵。都是22：30分保存的。注意，已经占用了2个post id了。接下来我们来看看如何使用这些修订记录。随便点击一个，将会出现如下页面。</p>
<p><a class="thickbox" title="修订记录对比" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/post_revision_2.jpg" target="_blank"><img height="228" alt="post revision comparison" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/post_revision_2.jpg" width="400" /></a></p>
<p>点击上图可以放大看全图。页面中间有个Compare revisions（对比修订）的按钮，下面有3行选项，分别对应3次不同内容，注意，是按时间降序排列的。第一行是current Revision，当前记录，也就是当前内容。第二行是第二次保存的修订版本，同理，第一行是第一次的修订记录。各行右边都有restore（恢复）按钮。</p>
<p>我们点击下compare revision看看。</p>
<p><a class="thickbox" title="对比修订记录中变更部分" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/post_revision_3.jpg" target="_blank"><img height="234" alt="对比修订记录变更部分" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/post_revision_3.jpg" width="400" /></a></p>
<p>WP会将当前版本和选中的修订记录分栏进行对比。注意，左右深色背景的方框，那都是内容差异部分。嘿嘿，这下几个修订版本间的变化都一目了然了吧。</p>
<p>至于那个restore按钮是用来干吗的？答案自然是将文章内容恢复到该修订版本去。这里就不抓图为例了。然后页面会转回到编辑页，并提示:</p>
<blockquote><p>Post restored to revision from 28 July, 2008 @ 22:30      </p>
<p>文章恢复到2008.07.28.22：30的修订版本。</p>
</blockquote>
<p>到此为止，如何使用它以及它的功能都清楚了吧。当然，数据库里一大堆相似度很高的文章以及post id占用，这些是这个保存修订记录功能附带的弊处吧。但方便对比查看各个不同时段的内容，这对于某些朋友可能有帮助。至于这功能真的没用么？我就不评论了，仁者见仁智者见智吧。</p>
<p><strong>p.s</strong>，文中没有列出自动保存的记录，二者在使用上一样的。如果存在自动保存记录的话，会在post revisions可以看到自动保存的记录，格式和修订版本一样，但标明autosave，如：</p>
<blockquote><p>*&#160; 27 July, 2008 @ 11:43 [Autosave] by 山之岚</p>
</blockquote>
<p>&#8220;嘿，这2.6的新东西可真多了啊。且不说单试用这些新功能，学习这些代码都够让我在一边窃笑了。Wordpress真是个好东西哦。&#8221;</p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/974.html#comments">评论8:</a></p><p><strong>8.</strong><i>2008.08.03.8:50.am</i>.&nbsp;<a href="http://www.surdark.net">浮黑</a>: 多谢岚兄和Yacca。
我的意思是说，平时写博客的时候总用中文全角标点。但写完后添加标签时需要用半角逗号区分，按快捷键可以临时变半角，但老忘了按……呵呵。
主要是我懒，估计也没什么办法。</p><p><strong>7.</strong><i>2008.08.02.2:00.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @牧狼羊: 用手机发表文章。累不累啊？</p><p><strong>6.</strong><i>2008.08.02.1:54.pm</i>.&nbsp;<a href="http://mlyang.cn">牧狼羊</a>: 昨晚用手机更新文章时，保存了两次，提示出现了两个修订版本。我用的Opera 4.0,后台又是全英文，以前从没见过这个功能，当时可真有点晕了，我心想这是啥呢，点Save不知道为什么无法发表，有错误提示。后来换用UCWEB才发表成功，汗一个。</p><p><strong>5.</strong><i>2008.07.29.9:19.pm</i>.&nbsp;<a href="http://www.eemir3.com">Yacca</a>: 腹黑...这其实是可以依靠插件来完成的.全角自动转成半角...我用了很久的.</p><p><strong>4.</strong><i>2008.07.29.7:15.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @浮黑: 这个应该和输入法软件有关吧。比如，我用搜狗拼音，按shift键可以切换中英文状态，也就是全（中）半（英）角标点输入，因为默认中文的标点是全角，而英文的标点是半角。在英文状态下，按shift+空格键可以切换到英文全角输入。不知是否有帮助。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p><p><strong>3.</strong><i>2008.07.29.6:40.pm</i>.&nbsp;<a href="http://www.surdark.net">浮黑</a>: 对了，请教岚兄，用WordPress写博客，很多地方都需要半角标点。你是如何快速切换全角半角的呢？</p><p><strong>2.</strong><i>2008.07.29.3:24.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @ddkk3000: 这是其一，其二是WP里面还有很多宝贝等着我们淘呢。p.s，在WP中表情符号的前后需要加上半角的空格，这样才会被识别为是表情符号，并正确转换。</p><p><strong>1.</strong><i>2008.07.29.3:20.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>:  <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ，是得写写，要不然大家装了新版，倒把新功能全屏蔽了。</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.12.19.12:20.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/1030.html" title=" 有段时间没有写些技术类的文章了，（p.s，似乎其它文章也没多写。。。">12行代码给Wordpress主题挂上AJAX (35)</a></p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.29.9:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/975.html" title="本文将继续来探讨Wordpress数据库查询的相关话题。文一里，我们知道了WP各">Wordpress数据库查询三板斧之三:如何查看WP数据库查询的具体内容 (7)</a></p><p><i>2008.07.27.12:02.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/973.html" title="自2.5起，WP提供了在线编辑时的自动保存功能。自然也是有利有弊。弊么，">Wordpress Hacks：如何管理WP自动保存功能 (10)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2008.07.25.1:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/969.html" title="Updated: 2008-07-26，更新Hook代码。  续上文，通过Wordpress基准页面数据库查询">Wordpress数据库查询三板斧之二:如何减少WP数据库查询次数和提高运行效率 (12)</a></p><p><i>2008.07.20.8:12.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/966.html" title="看了下面这张抓图，你就知道我为什么要做这个统计了。  
   昨晚上在DH的">Wordpress数据库查询三板斧之一:WP基准页面数据库查询次数统计 (12)</a></p><p><i>2008.07.16.12:15.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/954.html" title="升级至2.6后，除了插件管理页的布局更改外，似乎还没注意到其它显著的变">启用WP2.6 Turbo功能Step by Step (10)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/974.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/974.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>WordPress Hacks：如何管理WP自动保存功能</title>
		<link>http://www.thinkagain.cn/archives/973.html</link>
		<comments>http://www.thinkagain.cn/archives/973.html#comments</comments>
		<pubDate>Sun, 27 Jul 2008 03:47:56 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/archives/973.html</guid>
		<description><![CDATA[自2.5起，WP提供了在线编辑时的自动保存功能。自然也是有利有弊。弊么，无非又是数据库垃圾云云那套观点。利呢，废话么，就是自动保存了，万一浏览器崩溃（经常在FF上出现）或网络断线... ]]></description>
			<content:encoded><![CDATA[<p>自2.5起，WP提供了在线编辑时的自动保存功能。自然也是有利有弊。弊么，无非又是数据库垃圾云云那套观点。利呢，废话么，就是自动保存了，万一浏览器崩溃（经常在FF上出现）或网络断线等，期间所修改的内容还在。和那个<a href="http://www.thinkagain.cn/archives/971.html" target="_blank">2.6新提供的主题预览</a>一样，自然是正反2种喜好的人都有。实际这功能2.5就有了，而似乎是因为2.6的自动保存修订记录，才开始被关注。</p>
<p>至于如何管理自动保存功能。网络上流行较多的是用<a href="http://exper.3drecursions.com/2008/07/25/disable-revisions-and-autosave-plugin/" target="_blank">disable-autosave</a>插件来将其禁用。(p.s，该作者新出了disable-revision和disable-autosave and revision插件，在链接页可以下载)。</p>
</p>
<p>其实用不着启用一个插件去禁用它，或者说我是不大喜好给WP挂上一大堆插件。默认的自动保存时间间隔为60秒，可以在wp-config.php自定义自动保存的时间间隔。将时间间隔拉长，如1200（20分钟）或者3600（1小时），或更长，这样岂不就可以避免自动保存了。具体做法：</p>
<p>用文本编辑器打开根目录或其它目录下的wp-config.php，在require_once(ABSPATH.&#8217;wp-settings.php&#8217;)之前增加下列定义：</p>
<blockquote><p>define( &#8216;AUTOSAVE_INTERVAL&#8217;, 1200 );</p></blockquote>
<p>上述代码会将autosave时间间隔改为1200秒，20分钟。</p>
<p>感兴趣的朋友可以继续往下看。</p>
<p>进入wp数据库，打开wp_posts表，查看post_name一项。自动保存的文章，都会被命名为postid-autosave，如id为100的文章的自动保存记录的post_name为100-autosave。类似的WP2.6的自动修订记录的post_name为postid-revision-version。如100-revision为postid为100的文章修订版本1，100-revision-2为修订版本2。但是无论是自动保存或者修订记录，它们的post_type均为revision。也就是说二者性质是一样的。所以您要真看它们不顺眼，直接将post_type=revision的记录全部K掉吧。</p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/973.html#comments">评论10:</a></p><p><strong>10.</strong><i>2008.08.17.5:39.pm</i>.&nbsp;<a href="http://getfreeware.net/archives/479.html">关闭WordPress2.6的自动保存和文章版本控制功能 | 免费软件资讯站</a>: [...] 第三, 直接修改WP核心文件. 不推荐这种方法, 为什么呢? 首先是, 以后每次升级WordPress都要手动修改一次, 很麻烦. 其次, 从使用者的角度来说, 我们尽可能少修改核心文件是上策. 如果你喜欢捣鼓, 可以参考这篇文章中的办法来修改 - 如何管理WP自动保存功能. [...]</p><p><strong>9.</strong><i>2008.07.31.4:34.pm</i>.&nbsp;<a href="http://www.wavemood.net">2slow</a>: 版本修订我已经禁用了，自动保存还留着，防止浏览器崩溃。
定期删除数据库垃圾就成了。</p><p><strong>8.</strong><i>2008.07.29.9:19.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @浮黑: 文内的代码是按半角输入的，文章输出的时候就成了全角。有点纳闷。只好读者自己改吧。</p><p><strong>7.</strong><i>2008.07.29.8:24.am</i>.&nbsp;<a href="http://www.surdark.net">浮黑</a>: thinkagain，文中代码的引号写成全角了，要改成半角才行</p><p><strong>6.</strong><i>2008.07.29.8:15.am</i>.&nbsp;<a href="http://www.surdark.net">浮黑</a>: 好方法，这就去试试</p><p><strong>5.</strong><i>2008.07.27.2:21.pm</i>.&nbsp;<a href="http://www.eemir3.com">Yacca</a>: 原来如此简单-.-</p><p><strong>4.</strong><i>2008.07.27.2:15.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: 启动插件的原因可能是为了今后覆盖升级方便吧。</p><p><strong>3.</strong><i>2008.07.27.2:09.pm</i>.&nbsp;<a href="http://3284265.cn">shamas</a>: 貌似不行,我试了下,才几分钟就自动保存了</p><p><strong>2.</strong><i>2008.07.27.1:53.pm</i>.&nbsp;<a href="http://3284265.cn">shamas</a>: 应用,我也不想用插件,那个插件有点副作用,就是发表时看不到永久链接了</p><p><strong>1.</strong><i>2008.07.27.1:52.pm</i>.&nbsp;<a href="http://zz.neekey.com">neekey</a>: 沙发好舒服。我觉得自动保存功能还是挺有用的。
最好是在发布这篇文章后，自动删除保存的文章就好了</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.12.19.12:20.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/1030.html" title=" 有段时间没有写些技术类的文章了，（p.s，似乎其它文章也没多写。。。">12行代码给Wordpress主题挂上AJAX (35)</a></p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.29.9:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/975.html" title="本文将继续来探讨Wordpress数据库查询的相关话题。文一里，我们知道了WP各">Wordpress数据库查询三板斧之三:如何查看WP数据库查询的具体内容 (7)</a></p><p><i>2008.07.28.10:25.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/974.html" title="网上很多都在谈如何关闭WP2.6的修订记录保存功能。想必已经有很多WP爱好">Wordpress Tips：如何使用自动保存的修订记录 (8)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2008.07.25.1:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/969.html" title="Updated: 2008-07-26，更新Hook代码。  续上文，通过Wordpress基准页面数据库查询">Wordpress数据库查询三板斧之二:如何减少WP数据库查询次数和提高运行效率 (12)</a></p><p><i>2008.07.20.8:12.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/966.html" title="看了下面这张抓图，你就知道我为什么要做这个统计了。  
   昨晚上在DH的">Wordpress数据库查询三板斧之一:WP基准页面数据库查询次数统计 (12)</a></p><p><i>2008.07.16.12:15.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/954.html" title="升级至2.6后，除了插件管理页的布局更改外，似乎还没注意到其它显著的变">启用WP2.6 Turbo功能Step by Step (10)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/973.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/973.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>WordPress Hacks:如何关闭WP2.6的主题预览</title>
		<link>http://www.thinkagain.cn/archives/971.html</link>
		<comments>http://www.thinkagain.cn/archives/971.html#comments</comments>
		<pubDate>Sun, 27 Jul 2008 02:36:03 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/archives/971.html</guid>
		<description><![CDATA[WP2.6带来了很多新功能。相比2.3到2.5，2.5到2.6之间给我的惊喜更多。具体有什么新功能呢，这里就不细谈，百度一下或者在WP论坛搜一下，会出现一箩筐，我这里也不用再重复。比较全面介绍的... ]]></description>
			<content:encoded><![CDATA[<p>WP2.6带来了很多新功能。如后台的<a href="http://www.thinkagain.cn/archives/954.html">turbo</a>等。相比2.3到2.5，2.5到2.6之间给我的惊喜更多。具体有什么新功能呢，这里就不细谈，百度一下或者在<a href="http://wordpress.org.cn/">WP论坛</a>搜一下，答案一箩筐，我这里呢也不用再重复制造无用的东西。比较全面介绍的，可以参考下酋长的这篇文章：<a href="http://www.wopus.org/new-features-wordpress26.html" target="_blank">图文解说WordPress 2.6新功能</a>。此君费了不少工夫，应该要支持一下。呵呵。这里仅来谈谈WP2.6的主题预览。</p>
<p>2.6的新功能之一，就是可以即时主题预览。点击该主题的缩略图，会自动谈出一个thickbox窗口预览新主题。这样在测试新主题是，无需激活，在后台就可以看到新主题的效果了。既然有人喜好，那肯定也有人不中意。比如此<a href="http://wordpress.org.cn/thread-16715-1-1.html" target="_blank">兄台</a>。想关闭主题预览功能的话，很难很麻烦吗？当然，若是您一看代码就头晕的话，就此掠过。</p>
</p>
<p>用文本编辑器打开\wp-admin\themes.php，找到下列代码：</p>
<blockquote>
<p>add_thickbox(); </p>
<p>wp_enqueue_script( &#8216;theme-preview&#8217; );</p>
</blockquote>
<p>分别在它们前面加入注释符号&#8220;//&#8221;即可。如：</p>
<blockquote><p><span style="color: #008000">//add_thickbox();</span> </p>
<p><span style="color: #008000">//wp_enqueue_script( &#8216;theme-preview&#8217; );</span></p>
</blockquote>
<p>这样，当点击新主题时，就会直接激活该主题，和2.6版以前的一样。也就不会出现thickbox的主题预览效果了。很简单吧。</p>
<p>Do It Yourself!</p>
<p><strong>P.S，经常Hack WP源代码不是好习惯!</strong> </p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/971.html#comments">评论18:</a></p><p><strong>18.</strong><i>2011.06.26.1:56.pm</i>.&nbsp;<a href="http://www.hostjike.com">HostJike</a>: 我感觉没必要关闭啊！</p><p><strong>17.</strong><i>2008.10.07.10:59.pm</i>.&nbsp;<a href="http://8fone.com">Vee</a>: 多谢多谢 真是及时雨啊</p><p><strong>16.</strong><i>2008.08.31.1:36.pm</i>.&nbsp;<a href="http://www.leesum.com/blog/archives/225">金枫网络 &raquo; Blog Archive &raquo; 如何关闭WP2.6的主题预览</a>: [...] Google了下，找到热情的ThinkAgain详细的教我们如何关闭WP2.6的主题预览。 用文本编辑器打开wp-adminthemes.php，找到下列代码： [...]</p><p><strong>15.</strong><i>2008.07.29.10:12.am</i>.&nbsp;<a href="http://dickeydong.cn/">Dickey</a>: 博主很有钻研精神，佩服！！</p><p><strong>14.</strong><i>2008.07.28.11:11.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To oyster: 有的时候，如在本地调试的时候，就没有必要开预览来浪费时间了。</p><p><strong>13.</strong><i>2008.07.28.11:08.pm</i>.&nbsp;<a href="http://www.flywud.com">oyster</a>: 为什么要禁用呢 不是挺好用的不</p><p><strong>12.</strong><i>2008.07.27.2:23.pm</i>.&nbsp;<a href="http://www.eemir3.com">Yacca</a>: 这个功能蛮好的,我继续保留 哈哈</p><p><strong>11.</strong><i>2008.07.27.2:04.pm</i>.&nbsp;<a href="http://3284265.cn">shamas</a>: 我现在没打算再换主题,所以这个暂时保留</p><p><strong>10.</strong><i>2008.07.27.12:02.pm</i>.&nbsp;<a href="http://zz.neekey.com">neekey</a>: 这个功能还比较有用的</p><p><strong>9.</strong><i>2008.07.27.11:39.am</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: 暂时无法理解大家纷纷把新功能屏蔽掉的举动。</p><p><strong>8.</strong><i>2008.07.27.11:24.am</i>.&nbsp;<a href="http://www.wopus.org">酋长</a>: 是的。本身WordPress就是分享的精神~~~</p><p><strong>7.</strong><i>2008.07.27.11:17.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @酋长: 嗯，这点我是赞同的。想玩WP，不动手是不行地。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> 
哦，还有一点，也很重要，就是要分享。</p><p><strong>6.</strong><i>2008.07.27.11:13.am</i>.&nbsp;<a href="http://www.wopus.org">酋长</a>: 哈哈。。
文章已经被添加到图文解析的那篇文章里去了。。。

我觉得WordPress这些小的hack，才是玩WordPress的乐趣所在。。。HOHO</p><p><strong>5.</strong><i>2008.07.27.11:13.am</i>.&nbsp;<a href="http://www.mintspot.cn/?p=394">mintspot &raquo; Blog Archive &raquo; 如何关闭WP2.6的主题预览</a>: [...] 如何关闭WP2.6的主题预览 Firefox Add comments   2.6的新功能之一，就是可以即时主题预览。点击该主题的缩略图，会自动谈出一个thickbox窗口预览新主题。这样在测试新主题是，无需激活，在后台就可以看到新主题的效果了。既然有人喜好，那肯定也有人不中意。比如此兄台。想关闭主题预览功能的话，很难很麻烦吗？当然，若是您一看代码就头晕的话，就此掠过。&nbsp; [...]</p><p><strong>4.</strong><i>2008.07.27.11:07.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To 酋长，嗯，说的是。只不过，我的记性不好使。还不准回头就把这岔给忘记了。到时候人家说我的WP2.6有预览，我还纳闷干嘛我的会没有。呵呵。</p><p><strong>3.</strong><i>2008.07.27.10:58.am</i>.&nbsp;<a href="http://www.wopus.org">酋长</a>: 应该这么说：hack wp没什么。。但一定要做注解，好的注解+规范的代码修改。这样才不错。。。</p><p><strong>2.</strong><i>2008.07.27.10:45.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: 嘿，老改源代码不好，没看我的p.s内容么。呵呵。</p><p><strong>1.</strong><i>2008.07.27.10:43.am</i>.&nbsp;<a href="http://www.wopus.org">酋长</a>: 哈哈。。。代码就是这么神奇。。。</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2007.12.08.10:50.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/888.html" title="2007-12-09：注，我已经写了一个插件用于含有nextpage或more标签的feed全文输出">如何使用Wordpress内置的分页（Nextpage）功能？ (52)</a></p><p><i>2007.10.31.12:42.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/830.html" title="Updated:此问题已经在2.3.3中被修复。
*****************************
前几天，将Wordp">Wordpress Hacks:升级2.3.1可能出现邮件提醒失效的解决方法 (20)</a></p><p><i>2007.10.22.11:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/822.html" title="在wordpress中，默认点击评论者的链接时，会在同一窗口内打开该链接。这在">Wordpress Hacks: 在新窗口中打开评论者链接和no follow属性 (16)</a></p><p><i>2007.09.15.10:41.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/721.html" title="继将CSS修改符合W3C规范后，今天花了点时间，也将模板代码修改完毕，通过">继续修改模板 (4)</a></p><p><i>2007.08.21.8:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/611.html" title="又是一时心血来潮，试用过Wordpress后，想装上Movable Type 4.0玩玩看。于是就">图文介绍如何在本地服务器安装Movable Type 4.0 (15)</a></p><p><i>2007.06.11.3:55.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/189.html" title="由于博客上的图片大部分都是放在Flickr上的，所以Flickr被禁后导致国内朋友">WordPress解决Flickr图片显示方法 (3)</a></p><p><i>2007.04.30.8:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/161.html" title="Widgets是一个可视化Wordpress主题侧边栏编辑插件，用户可以在Wordpress后台主">如何修改代码使主题支持widgets (5)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/971.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/971.html/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>WordPress数据库查询三板斧之二:如何减少WP数据库查询次数和提高运行效率</title>
		<link>http://www.thinkagain.cn/archives/969.html</link>
		<comments>http://www.thinkagain.cn/archives/969.html#comments</comments>
		<pubDate>Fri, 25 Jul 2008 05:06:04 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[查询]]></category>
		<category><![CDATA[次数]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/?p=969</guid>
		<description><![CDATA[续上文，通过Wordpress基准页面数据库查询次数统计，让我们对WP运行各页面所需最少查询数有个基本了解。分析这些基准页面所需的数据库查询次数的目的当然是想减低它们，以提高WP运行效率... ]]></description>
			<content:encoded><![CDATA[<p><strong>Updated: 2008-07-26，更新Hook代码</strong>。</p>
<p>续上文，通过<a href="http://www.thinkagain.cn/archives/966.html">WordPress基准页面数据库查询次数统计</a>，让我们对WP运行各页面所需最少查询数有个基本了解。分析这些基准页面所需的数据库查询次数的目的当然是想减低它们，以提高WP运行效率了。本文将就如何<u>不借助外部方法</u>，仅利用Wordpress自带技术来减少Wordpress数据库查询次数和提高运行效率，谈谈我的个人做法和思路。欢迎拍砖。本文假设阅读者应了解WP的基本知识，并能操作简单的PHP代码。</p>
<p>要想减少数据库的查询次数，首先要对模板进行分析，了解到模板中的哪个部分功能需要调用数据库，以及哪些些插件需要读写数据库。然后在此基础上，再来分析下减少的可能性。此文主要以模板为例，插件部分暂且不谈。以<a href="http://www.thinkagain.cn" target="_blank">ThinkAgain</a>现用模板为例，来分析下页面中的哪几个部分需要读取数据库。如在首页的<font style="background-color: #ffffff" color="#444444">最新留言，</font><font style="background-color: #ffffff" color="#444444">最新存档，目录树和标签云等这些都需要从数据库中读取相应的数据，至于日历，WP已经内置了缓存。进一步考虑下，这些东西在未有新事件前，(如新留言或新文章发布等)，每次加载页面读取数据库并生成的html代码的内容都是一样的，既然如此有必要在每次加载页面时，重复这些事情，如果能将这部分内容缓存起来岂不就可以减少数据库读取次数以及提高WP运行效率了吗？OK，这个就是我对精简数据库查询次数的主要思路之一。当然，接下来要解决如何实现缓存问题以及自动更新的问题。</font></p>
</p>
<p>先来看一组数据，让数字来说话。</p>
<p><a class="thickbox" title="数据库查询次数对比" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/querytimes.gif" target="_blank"><img height="149" alt="数据库查询次数对比" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/querytimes.gif" width="400" /></a></p>
<p>上图是DH提供的数据库使用情况统计数字，可以看出，从19日到21日，每次数据库链接所消耗的查询次数均值大概在<strong>29.1~30.6</strong>，22日下午开始换上更改后的代码，启用缓存，22日平均查询次数降低到25.2，23日的平均值就更低了约为<strong><u>20</u></strong>次。大约降低了33%左右。效果还是很显著的吧。</p>
<p>接下来，来谈谈具体如何缓存以及如何解决即时更新的问题。</p>
<p>1. 缓存问题</p>
<p>缓存数据的方法虽然很多，其实按性质划分起来无非就只有2种，缓存到数据库或者缓存文件。后者，记得水煮鱼写过一篇<a href="http://fairyfish.net/2008/06/23/cache-sidebar/" target="_blank">怎样缓存sidebar</a>的文章，简单地说，其思路为利用output control function将侧边栏内容缓存到sidebar.html文件中，然后定时进行更新。此法可以解决缓存问题以及减少数据库查询，唯一不足的就是在指定间隔时间内容，新留言的无法自动更新。p.s，这问题实际上利用WP运行机制是可以解决的。</p>
<p>而我的方法是将数据缓存到数据库中，然后在使用时仍然从数据库中读取。如此做法不是还要读取数据库么？怎么会减少数据库查询次数呢？先别急，且听我慢慢道来。</p>
<p>默认WP有10个数据表，wp_posts和comments主要存储文章内容和评论，其它的几个包括term等存储了目录和标签等等。这里不细谈。wp_options用来存储Wordpress以及插件运行时所涉及的配置等。且WP会在运行时自动读取该表的内容。换句话说，因为WP已经预读这部分内容，所以直接调用wp_options内的数据是不会产生数据库查询的。到此为止，谜底已经揭开了一大半了。高手们不用往下看，也都知道怎么做了吧。呵呵。</p>
<p>2. 即时更新问题</p>
<p>有了新留言或发布了新文章，自然想马上在页面中显示出来，这就需要即时更新已缓存在wp_options里面的数据。要解决这个问题，自然还是要从Wordpress的运行机制方面下手。</p>
<p><a href="http://www.thinkagain.cn/archives/966.html" target="_blank">此文</a>中，我曾简单地谈过WP是个好东西，提供了一个框架平台，也开放了很多预定义的接口给用户自定义。从系统分析的角度来看，WP也是个离散系统。从用户点击网址，WP解析url开始等，发表评论或文章等等，这些都可以视为一个离散事件。而WP提供了很完备的Hook用于用户对这些事件进行控制。</p>
<p>缓存的内容涉及最新留言，或文章数的显示等，这些无非都需要在新留言或新文章发布这些事件发生后激活更新缓存。理解了这点，也就很容解决问题了。发布新留言和新文章的Hook接口为：</p>
<blockquote><p>add_action(&#8216;comment_post&#8217;, &#8216;Your_Function&#8217;); //comment发布Hook</p>
<p>add_action(&#8216;publish_post&#8217;, &#8216;Your_Function&#8217;); //post发布Hook</p>
</blockquote>
<p>2个问题都清楚，画个流程图也很简单了。</p>
<p><a class="thickbox" title="流程图" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/cache.gif" target="_blank"><img height="333" alt="流程图" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/cache.gif" width="300" /></a></p>
<p>行文至此，我已经将这个问题的Know-How解释清楚了。老鸟么，可以到此止步。小鸟们继续往下看我给的一个例子。</p>
<p>下面我将给出一个自己写的将最新留言缓存到wp_options表中，以及读取最新留言的2个函数(共3个函数)。有兴趣可以Copy下来放在自己模板的Function.php中，就可以激活使用了。然后在侧边栏的显示最新留言位置，将原来代码替换成</p>
<p>&lt;?php cache_recent_comments();?&gt;</p>
<p>就可以了。</p>
<p>简单介绍下，cache_recent_comments()函数用来显示缓存后的最新留言，cache_get_recent_comments()用来获取最新留言并缓存到wp_options表中。my_utf8_trim()，这个函数是中文工具箱的，其作用在于避免留言被截断后尾部出现乱码。在这里放上来，免得有些网友没有装中文工具箱造成不便。</p>
<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
<div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #008000">//显示缓存后的最新留言</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> function cache_recent_comments(){</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     $cached = get_option(<span style="color: #006080">'multicolor_cache_recent_comments'</span>);<span style="color: #008000">//从options表中获取已缓存的最新留言</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">if</span>($cached){    <span style="color: #008000">//如果最新留言已缓存，直接显示，否则获取最新留言并缓存到options表中。</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>         echo $cached; </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     }<span style="color: #0000ff">else</span>{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>         $cached = cache_get_recent_comments();</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         echo <span style="color: #006080">&quot;Cache Updated&quot;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         echo $cached;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span> <span style="color: #008000">//获取最新留言并缓存到options表中</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span> function cache_get_recent_comments() {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     $commentnumber = 6;    <span style="color: #008000">//显示最新留言数目</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>     $before = <span style="color: #006080">'&lt;li&gt; '</span>;    <span style="color: #008000">//留言前后html标签</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>     $after = <span style="color: #006080">'&lt;/li&gt;'</span>;    </pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>     $length = 150;        <span style="color: #008000">//截取留言的长度</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>     global $wpdb;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>     $sql = <span style="color: #006080">&quot;SELECT ID, comment_ID, comment_author_url, comment_content, comment_author FROM $wpdb-&gt;posts, $wpdb-&gt;comments WHERE $wpdb-&gt;posts.ID=$wpdb-&gt;comments.comment_post_ID AND ($wpdb-&gt;posts.post_status = 'publish')&quot;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>     $sql .= <span style="color: #006080">&quot;AND comment_approved = '1' ORDER BY $wpdb-&gt;comments.comment_date DESC LIMIT $commentnumber&quot;</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>     $comments = $wpdb-&gt;get_results($sql);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>     $output = <span style="color: #006080">''</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>     <span style="color: #0000ff">foreach</span> ($comments <span style="color: #0000ff">as</span> $comment) {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>         $comment_author = stripslashes($comment-&gt;comment_author);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>         $comment_author_url = stripslashes($comment-&gt;comment_author_url);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>         $comment_content = strip_tags($comment-&gt;comment_content);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>         $comment_content = stripslashes($comment_content);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>         $comment_excerpt =substr($comment_content,0,$length);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span>         $comment_excerpt = convert_smilies($comment_excerpt);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  30:</span>         $comment_excerpt = my_utf8_trim($comment_excerpt);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  31:</span>         $permalink = get_permalink($comment-&gt;ID).<span style="color: #006080">&quot;#comment-&quot;</span>.$comment-&gt;comment_ID;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  32:</span>         <span style="color: #0000ff">if</span> (!empty($comment_author_url)){</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  33:</span>         $comment_author_link = <span style="color: #006080">'&lt;a style=&quot;font-style: italic;color:#444;border-bottom:1px dashed #888&quot; title=&quot; '</span>. $comment_author_url.<span style="color: #006080">'&quot; target=&quot;_blank&quot; href=&quot;'</span>. $comment_author_url . <span style="color: #006080">'&quot;&gt;'</span>. $comment_author . <span style="color: #006080">'&lt;/a&gt;'</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  34:</span>         }<span style="color: #0000ff">else</span>{</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  35:</span>             $comment_author_link = <span style="color: #006080">'&lt;a style=&quot;font-style: italic;color:#444;border-bottom:1px dashed #888&quot; title=&quot; View the entire comment by '</span> . $comment_author . <span style="color: #006080">'&quot; target=&quot;_blank&quot; href=&quot;'</span>. $permalink  . <span style="color: #006080">'&quot;&gt;'</span>. $comment_author . <span style="color: #006080">'&lt;/a&gt;'</span>;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  36:</span>         }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  37:</span>         $output .= $before . $comment_author_link . <span style="color: #006080">': '</span> . <span style="color: #006080">'&lt;a target=&quot;_blank&quot; href=&quot;'</span> . $permalink . <span style="color: #006080">'&quot; title=&quot;View the entire comment by '</span> . $comment_author . <span style="color: #006080">'&quot;&gt;'</span>  . $comment_excerpt . <span style="color: #006080">'...'</span> . <span style="color: #006080">'&lt;/a&gt;'</span>  . $after;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  38:</span>         }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  39:</span>         update_option(<span style="color: #006080">'multicolor_cache_recent_comments'</span>, $output); <span style="color: #008000">//更新缓存在options表中的最新留言</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  40:</span>         <span style="color: #0000ff">return</span> $output;</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  41:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  42:</span> <span style="color: #008000">//中文工具箱的函数，用于砍掉汉字截断尾巴可能存在的乱码。</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  43:</span> function my_utf8_trim($str) {</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  44:</span>     $len = strlen($str);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  45:</span>     <span style="color: #0000ff">for</span> ($i=strlen($str)-1; $i&gt;=0; $i-=1){</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  46:</span>         $hex .= <span style="color: #006080">' '</span>.ord($str[$i]);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  47:</span>         $ch = ord($str[$i]);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  48:</span>         <span style="color: #0000ff">if</span> (($ch &amp; 128)==0) <span style="color: #0000ff">return</span>(substr($str,0,$i));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  49:</span>         <span style="color: #0000ff">if</span> (($ch &amp; 192)==192) <span style="color: #0000ff">return</span>(substr($str,0,$i));</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  50:</span>     }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  51:</span>     <span style="color: #0000ff">return</span>($str.$hex);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  52:</span> }</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  53:</span>     <span style="color: #008000">//通过此添加此Hook以保证最新留言能够被缓存到options表中。</span></pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  54:</span>     add_action(<span style="color: #006080">'comment_post'</span>, <span style="color: #006080">'cache_get_recent_comments'</span>);</pre>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  55:</span>     add_action(<span style="color: #006080">'edit_comment'</span>, <span style="color: #006080">'cache_get_recent_comments'</span>);</pre>
</p></div>
</div>
<p>上述代码只是个例子，仅仅提供了缓存最新留言的功能。这里将代码放上来，目的在于参考。拿来主义固然可以解决目前问题，自己动手方能巩固所学。Do It Yourself才是真正的乐趣。否则的话，玩转WP也就失去意义了。</p>
<p>或许有些网友可能会说，做这些事情干什么？直接静态化不就可以了。通过直接生成实际的html文件固然有其好处，完全不需要php解析和数据库查询等，然后实际应用中，还需要解决一些问题，如一些互动信息，最新留言文章等，一旦静态化后，这部分内容就被定格了。再则，静态化插件很容易和一些下载插件存在兼容性问题，在点击这些下载插件生成的url时，很容易出现返回404错误。等等。</p>
<p>通过分析模板内容，我写了几个简单的函数将各页面中的通用部分缓存到数据库中，可以在一定程度上减少数据库查询次数。如原来这个模板首页需要36次查询，现在为25次。文章页为41次查询，现在为32次。当然，此法并非能解决所有问题，如文章页中的推荐阅读，因为推荐阅读涉及2个方面，一是和该post相关，也就是说要传递post id，在wp_options中给每个post id分个键值，显然是不可取的，二是推荐阅读的内容能自动和新发布文章挂钩。</p>
<p>实际上，我现在模板的数据库查询还是非常高的，主要是当时制作时根本就没有考虑这方面的影响。如果能在模板制作时，将数据库查询问题考虑进去，这样就能最大程度地减低查询数了。</p>
<p>以上的东西能否制作成插件？答案是可以的。制作一个插件提供缓存的留言，文章，标签等功能的显示，乃至可以提供现有wp内置widget提供功能的缓存。然而这并非是我写此文的目的了。<strong><u>分享和探讨</u></strong>，这才是我的初衷。当然如果需要多了，写个插件也未尝不可。</p>
<p>p.s，关于插件制作，上次和牛人<a href="http://www.pkphp.com" target="_blank">Askie</a>瞎聊过这方面的事情。也没有整理，直接放上来。至于为何称此君为牛人呢，您说连Blog地址都是pkphp，能和php PK的人，能不牛乎？</p>
<blockquote>
<p>me: 其实现在插件很多了。</p>
<p>10:34 PM 写一些普通作用的插件也没什么意思的。关键是idea。</p>
<p>我挺欣赏你的那个加水印的插件</p>
<p>imaskie: 哈哈</p>
<p>看见你的夸奖了</p>
<p>10:35 PM me: 要写就弄些有点新意的东西，要么就不要再去折腾普通的插件。</p>
<p>imaskie: 奥</p>
<p>10:36 PM 人家有的就不去重复了</p>
<p>me: 弄普通的插件，这么浪费你这人才么，呵呵</p>
<p>imaskie: 哈哈</p>
<p>me: 人家有的，再去弄，除非方法或效率方面有提高，否则有什么意思。你说呢。</p>
<p>imaskie: 是呀</p>
<p>10:37 PM me: 这就像转载人家文章似的。</p>
<p>imaskie: 恩</p>
<p>看见你的博客里的内容了</p>
<p>都是原创</p>
<p>很有技术</p>
<p>不错</p>
<p>me: 哎，谢谢夸奖啊。都是自己在瞎弄。</p>
<p>10:38 PM 要不瞎弄，怎么玩wp。呵呵</p>
<p>其实坛子上很多朋友的问题，只需要他们自己动手测试下，大部分都可以自己解决的。</p>
</blockquote>
<p>OK，到此结束，欢迎拍砖。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/969.html#comments">评论12:</a></p><p><strong>12.</strong><i>2011.09.13.6:56.pm</i>.&nbsp;<a href="http://ruantoo.me">ruantoo</a>: 这个学习了~~~~   我的数据库 查询达到112次  亲娘 要命呀 真该急救了 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' /> </p><p><strong>11.</strong><i>2011.04.22.8:41.am</i>.&nbsp;<a href="http://www.dhblog.org">DH</a>: 我知道了，是个空间商的名字</p><p><strong>10.</strong><i>2011.04.15.12:46.pm</i>.&nbsp;<a href="http://www.dhblog.org">DH</a>: “DH提供的数据库使用情况统计数字” 这个DH是什么啊？</p><p><strong>9.</strong><i>2008.08.01.2:35.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: 磁盘缓存载入快还是数据库直接载入快，这个没有弄懂。</p><p><strong>8.</strong><i>2008.07.26.9:56.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To Oyster: 呵呵，这里我也要纠正你的一些错误观点哦。
1.WP本身并不具有缓存机制。但如果你的php支持一些缓存扩展，如memcached，且在wp-config.php中开启wp_cache。wp的缓存机制才会利用这些缓存扩展运行。
2.之所以会被认为wp有缓存机制，是因为wp在打开页面时候，就默认将wp_options里面autoload为true的键值（数据）加载了。这也就是我的方法不需要数据查询的原因之一，因为它们已经默认被加载了。
3.mysql是非常优秀的数据库，其本身查询所消耗的时间，视代码而定，一般都很少，如0.0几秒等，但实际上因为mysql工作载荷如同时查询数等等，你可以看到wp的每个查询都会消耗0点几秒的。这点下篇文章中将会指出。
对否，可以讨论下哦。呵呵。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p><p><strong>7.</strong><i>2008.07.26.9:15.pm</i>.&nbsp;<a href="http://www.flywud.com">oyster</a>: wp 本身是有缓存机制的，但是很多插件 在使用时为图方便 就没有按机制来 所以就造成了 一些问题。

这里我还要纠正一些错误观念。
------------
5Dianso
2008.07.26 Saturday 11:35 am 

我十几个widget都保存到数据库了,肯定每次都需要查询,效率很低了

----------

就是这种概念，访问数据库 并不会直接造成速度的慢。
mysql 是世界数据库系统中排前5的了，相信设计得当，处理上亿数据级的都是没有问题的。。

整的来说 访问内存 即缓存 速度是最快的 但是内存是有限，接下来是虚拟内存，即硬盘的分页区。但是他们都是有限的而且，使用的还不止你一个程序，然后就是本地文件读取跟数据库了，事实上在大数据的存取时数据库会比本地文件的读取更快。

所以不要盲目迷信 数据库慢，数据库慢的原因，大多是任务多而引起排队的 呵呵 

最后我也还没搞清楚WP的缓存机制。呵呵</p><p><strong>6.</strong><i>2008.07.26.3:53.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To Dianso：widget多不见得查询数就多哦。要看看该widget是否读写数据库。</p><p><strong>5.</strong><i>2008.07.26.11:35.am</i>.&nbsp;<a href="http://014.cc">Dianso</a>: 我十几个widget都保存到数据库了,肯定每次都需要查询,效率很低了</p><p><strong>4.</strong><i>2008.07.25.9:53.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: 还是用缓存？等我仔细看看。</p><p><strong>3.</strong><i>2008.07.25.7:16.pm</i>.&nbsp;<a href="http://www.charlestang.cn">Charles</a>: 不错，先顶再看……</p><p><strong>2.</strong><i>2008.07.25.2:25.pm</i>.&nbsp;<a href="http://3284265.cn">shamas</a>: 学习中</p><p><strong>1.</strong><i>2008.07.25.2:05.pm</i>.&nbsp;<a href="http://zz.neekey.com">neekey</a>: 沙发~~~~~~~~~
WP应该自己建立一个缓存体系，并且有开关控制选择性开启，而不是依靠插件，否则只会越缓存效率越低？</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.07.29.9:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/975.html" title="本文将继续来探讨Wordpress数据库查询的相关话题。文一里，我们知道了WP各">Wordpress数据库查询三板斧之三:如何查看WP数据库查询的具体内容 (7)</a></p><p><i>2008.07.20.8:12.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/966.html" title="看了下面这张抓图，你就知道我为什么要做这个统计了。  
   昨晚上在DH的">Wordpress数据库查询三板斧之一:WP基准页面数据库查询次数统计 (12)</a></p><p><i>2008.12.19.12:20.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/1030.html" title=" 有段时间没有写些技术类的文章了，（p.s，似乎其它文章也没多写。。。">12行代码给Wordpress主题挂上AJAX (35)</a></p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.28.10:25.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/974.html" title="网上很多都在谈如何关闭WP2.6的修订记录保存功能。想必已经有很多WP爱好">Wordpress Tips：如何使用自动保存的修订记录 (8)</a></p><p><i>2008.07.27.12:02.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/973.html" title="自2.5起，WP提供了在线编辑时的自动保存功能。自然也是有利有弊。弊么，">Wordpress Hacks：如何管理WP自动保存功能 (10)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2008.07.16.12:15.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/954.html" title="升级至2.6后，除了插件管理页的布局更改外，似乎还没注意到其它显著的变">启用WP2.6 Turbo功能Step by Step (10)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/969.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/969.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>WordPress数据库查询三板斧之一:WP基准页面数据库查询次数统计</title>
		<link>http://www.thinkagain.cn/archives/966.html</link>
		<comments>http://www.thinkagain.cn/archives/966.html#comments</comments>
		<pubDate>Sun, 20 Jul 2008 12:01:06 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[查询]]></category>
		<category><![CDATA[次数]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/?p=966</guid>
		<description><![CDATA[看了下面这张抓图，你就知道我为什么要做这个统计了。昨晚上在DH的Panel里面查看站点运行情况报告，真可谓，不看不知道，一看吓一跳。竟然看到里面报告19日当日的数据库连接高达6000多次... ]]></description>
			<content:encoded><![CDATA[<p>看了下面这张抓图，你就知道我为什么要做这个统计了。</p>
<p><a class="thickbox" title="数据库查询次数" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/dbqueries.jpg" target="_blank"><img height="158" alt="数据库查询次数" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/dbqueries.jpg" width="400" /></a> </p>
<p>昨晚上在DH的Panel里面查看站点运行情况报告，真可谓，不看不知道，一看吓一跳。竟然看到里面报告19日当日的数据库连接高达6000多次，数据库查询多达19万次。由于报告中的日期并不连续，少了16，17和18的数据。所以我估计19日的数据可能是这几天数据利用情况的合计值吧。以15日为例，当日的连接次数和查询次数也分别高达2607和78922。所以且不管这是当日统计或是多日的合计，总之，给我一个印象就是一个字，<strong>多</strong>。</p>
</p>
<p>其实早在去年就和<a title="风暴轻狂" href="http://lxz.name" target="_blank">风暴轻狂</a>聊过这个Wordpress数据库查询次数过多的问题，在去年11月写<a href="http://www.thinkagain.cn/archives/877.html" target="_blank">wp_list_posts</a>这个小插件的时候，曾提到调用一次WP内置的get_permalink()都会产生一次数据查询，而其实在一个WP的Loop内，由于已经将post相关的参数如id，postname等都预读取了，没有必要（视永久链接结构而定）在模板中再次调用get_permalink()来生成永久链接。毋庸置疑，WP是个很优秀的个人博客发布平台，其内置了相当丰富的模板函数（Template Tag）用于模板制作，最大的优点就是开放API接口（Hook）支持用户自定义操作（通过插件）以实现各样功能。简单地以建房为例子来说，WP就好比是提供了一个未装修的房子框架，建好WP后，用户直接就可以入住了。各式各样的模板就好比如是装潢设计，各种插件好比是具有一定功能的家具或电器等。如果你对其不了解，直接选择最普通的、千篇一律的设计（使用默认模板），直接也可以使用。如果你想把自己的家弄得有个性，就可以利用WP的内置函数来设计模板，为了使小家更舒适更愉快，你可以挂上一些特定插件来实现。夏天到了，你可能会挂空调，冬天用暖气。而Widget提供了一个捷径给用户以实现其自定义功能。所以如果为了保证其考虑到不同用户的使用情况，WP会强调其标准化。然则东西一旦做大做泛了，其兼容性自然难以保证。很容易产生了WP和插件，以及版本，数据库等之间的兼容性问题。这里的兼容性很大程度上并不单单是说WP和用户平台等之间的兼容性，各个插件之间因不兼容存在的问题更多的。很简单，你在房子里面东西加载了一大堆，虽然东西是按房子标准建立或加载的，但做东西的人不见得会考虑对其它产品的交叉影响，且作为用户也很难考虑到各个东西是否能一起使用，也就是这个道理了。实际上WP本身，若不是去接触其内核的话，仅仅是想做到自己做模板设计的话，还是很简单的，用户甚至不必对php有太深的了解。只需要通过了解一些简单的操作如变量定义，流程控制以及熟悉WP内置的模板函数调用就可以了，还有基本Html和css知识，就可以制作出自己心仪的模板了。若是想深入了解的话，就应该去接触WP的运行流程，Hook，数据库结构以及rewrite rule等等。</p>
<p>回到数据库查询吧。ThinkAgain现用的这个Multi Color模板，从首页到文章页，以及页面页等，大概数据查询次数在30-40次之间，视使用不同插件，查询次数会有些差异。如我将文章页中的上下文章导航禁用，可以少了4次数据查询。将侧边栏（主要调用了评论和最新文章目录等）关闭，会少7个查询。将get_permalink关闭可以少1次，移到wp_link_page也可以少1次查询等等。关闭评论也可以少1次查询。关闭下面相关文章推荐，竟然可以少了10个查询。</p>
<p>在具体进入测试之前，先介绍下统计WP数据查询次数的函数：</p>
<p>&lt;?php echo get_num_queries(); ?&gt; ，用来显示该页面的数据库查询次数。</p>
<p>因为各个模板加载的函数等都不同，所以为了使得数据有可参照性，我在本地新建了WP2.51和WP2.6版本的2个博客用于测试。2个博客分别加载默认模板，禁用所有插件。采用默认Widge，各发布了6个文章和3个页面，将首页显示文章数改为3，用于翻页函数的查询。测试发现，WP2.6的查询次数竟然比2.51少了3次。可见升级的好处还不少吧。在此将WP2.6和WP2.51的结果放出来。显示格式为，测试页面：查询次数（WP2.6，WP2.51）。</p>
<blockquote><p>首页: 18次，21次</p>
<p>文章页: 15次, 18次</p>
<p>页面页: 17次，20次</p>
<p>目录页: 16次，19次</p>
<p>时间存档页：16次，19次</p>
<p>标签页: 17次，20次</p>
<p>搜索页：16次，19次</p>
<p>404页：10次，13次。</p>
</blockquote>
<p>自定义页面页（加载自定义页面模板）：9次。注，自定义页面模板内置查询次数的函数代码。</p>
<p>对比看来，实际上我们在用的模板比默认模板的查询次数多了好多。当然这些主要是一些插件造成的。如在侧边栏调用最新评论等。</p>
<p>下面来具体看看一些常用函数需要多少个数据库查询。分别将index.php（首页），single.php（文章页）和page.php（页面页）代码全部清空，测试其加载页面的数据库查询次数，结果有点结舌。</p>
<blockquote><p>空白index.php：10次，13次</p>
<p>空白single.php：9次，12次</p>
<p>空白page.php: 9次，12次。</p>
</blockquote>
<p>仅加载一个页面就需要这么多次数据库查询。汗，这效率可不见得高。记得<a title="风暴轻狂" href="http://lxz.name" target="_blank">风暴轻狂</a>曾给我说过discuz似乎只用4个查询。接着以WP2.6默认模板的首页为例，我们来分析下，是什么功能消耗了这些数据库查询。</p>
<p>关闭加载Header数据库查询为15次，即少了3次数据查询。可Header里面仅仅是调用bloginfo()以及get_option()，WP对这些变量都进行缓存了，调用这些语句是不会发生数据库查询的，那么消耗3次数据库查询的是何方神圣呢？答案是：&lt;?php wp_head(); ?&gt;，这个语句是实际上是一个WP Hook，提供了一个接口给一些需要调用数据库数据在页面头部写代码的插件。插件是通过：</p>
<blockquote><p>add_action(&#8216;wp_head&#8217;, &#8216;函数名称&#8217;);</p>
</blockquote>
<p>来将代码插入头部的，如插件运行需要的css文件地址或需要加载的js地址等。所以这个接口消耗的数据库查询数，应该是和使用插件的个数有关。默认是消耗3个。用于添加Nofollow（如果选择禁止搜索引擎抓取博客的话），EditUrl和wlwmanifest，前者是用于标识博客RPC发布网址，后者应该是为Windows Live Writer专用的接口wlwmanifest.xml的绝对地址。</p>
<p>同样位于footer的&lt;?php wp_footer(); ?&gt;和sideba的&lt;?php wp_meta(); ?&gt;视插件而定，也可能会消耗查询。默认模板下是没有消耗查询数据。</p>
<p>关闭加载Sidebar（侧边栏）的查询次数为13次，也就是少了5次查询。其中wp_list_pages和wp_get_archives各消耗1次，而wp_list_bookmarks会产生2次查询。还有1次的查询是wp_register()造成的。wp_register()是用来生成注册按钮（如果选择用户可注册时，用户浏览时显示）或显示Site Admin（管理者浏览时显示）。</p>
<p>而以上就是WP2.6在默认模板下的数据库查询次数及其消耗情况。而为什么加载一个空白页面也需要那么多数据库查询的答案也就出来了，也就是即使模板中没有加任何代码，但是WP在运行时已经默认通过地址解析等到的参数来判断是否是首页或页面，文章页等，自动查询了数据库以加载资料，这些东西都被存放在$post等全局变量里面。</p>
<p>在简单分析下single.php的数据库查询消耗情况，previous_post_link和next_post_link各消耗1次。comments_template();消耗1次。仅次而已。</p>
<p>汇总下，仅列出WP2.6的数据，</p>
<blockquote><p>首页: 18次，文章页: 15次, 页面页: 17次，目录页: 16次，时间存档页：16次，标签页: 17次，搜索页：16次，404页：10次。</p>
<p>wp_list_pages，wp_get_archives，wp_register，previous_post_link，next_post_link，comments_template这些函数各消耗1次。</p>
<p>wp_list_bookmarks消耗2次查询。</p>
</blockquote>
<p>从对比上看，很明显WP在2.6版中对数据库查询等方面做了改进，估计可能是在和post相关的方面，这些等对比完代码后，再发上来。当然最重要的是如何减少这些数据库查询，这些也得等个人调试顺利后，慢慢再总结吧。</p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/966.html#comments">评论12:</a></p><p><strong>12.</strong><i>2008.08.01.2:23.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: “曾提到调用一次WP内置的get_permalink()都会产生一次数据查询，而其实在一个WP的Loop内”——怎么没说明怎么修改呢。</p><p><strong>11.</strong><i>2008.07.23.9:06.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To mygtd，呵呵，那敢情好啊。自己做的php blog，这样才最爽，因为什么部分该怎么修改或改进等，都可以自由掌握。</p><p><strong>10.</strong><i>2008.07.23.8:53.pm</i>.&nbsp;<a href="http://www.mygtd.cn">mygtd</a>: 我不是用WP的，只是自己做PHP站的BLOG</p><p><strong>9.</strong><i>2008.07.22.2:32.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @oyster: 没有好的wp技术文档？推荐你一个吧。http://codex.wordpress.org/Developer_Documentation 。 我的绝大部分WP方面的知识都是从这里来的。</p><p><strong>8.</strong><i>2008.07.22.1:53.pm</i>.&nbsp;<a href="http://www.flywud.com">oyster</a>: 没有一个好的wordpress技术文档 
我查的几个都很不完整.内容 
还是需要自己再努力去找源头.呵呵</p><p><strong>7.</strong><i>2008.07.21.7:29.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: @山之岚 呵呵，除万非得以，才静态。你现在的博客访问速度比原来在bh（或是hm）上，快多了。把服务器搞的更快是加速的硬道理。

@shamas 你那个查询次数，并不是每次访问时的，而是深层时的，所以没有关系。</p><p><strong>6.</strong><i>2008.07.21.4:07.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @shamas: 生成静态的话，是不存在数据库查询问题的。只是生成静态文件有利有弊，如由于是读取实际存在的文件，不需php解释和数据库查询，加载页面的速度固然会加快，但是如果你在页面上加载一些效果，如显示页面浏览数，以及涉及url rewrite的，如和一些下载插件存在冲突等，这些问题就会浮出来的。</p><p><strong>5.</strong><i>2008.07.21.4:00.pm</i>.&nbsp;<a href="http://3284265.cn/">shamas</a>: 我现在虽然生成了静态,不过调用也一样高</p><p><strong>4.</strong><i>2008.07.21.11:47.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @ddkk3000: 严格地说，少了3次，已经不少了。如以加载空白页面为例计算，已经是降低了30%的查询了。可以想象，如果一个博客访问量大的话，这性能差距就不少了。至于2.6是否被慢？我倒是没有察觉出来。呵呵</p><p><strong>3.</strong><i>2008.07.21.10:37.am</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: 少几次意义不大，我感觉2.6比以前的版本慢。</p><p><strong>2.</strong><i>2008.07.20.9:35.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @yixia: 我测试的是少了3次。估计都是和post相关方面的。等对比下代码看了再说，没有调查就没有发言权。呵呵。</p><p><strong>1.</strong><i>2008.07.20.9:32.pm</i>.&nbsp;<a href="http://www.e-xia.com">yixia</a>: 我也发现2.6是比2.51少了两次查询，呵呵</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.07.29.9:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/975.html" title="本文将继续来探讨Wordpress数据库查询的相关话题。文一里，我们知道了WP各">Wordpress数据库查询三板斧之三:如何查看WP数据库查询的具体内容 (7)</a></p><p><i>2008.07.25.1:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/969.html" title="Updated: 2008-07-26，更新Hook代码。  续上文，通过Wordpress基准页面数据库查询">Wordpress数据库查询三板斧之二:如何减少WP数据库查询次数和提高运行效率 (12)</a></p><p><i>2008.12.19.12:20.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/1030.html" title=" 有段时间没有写些技术类的文章了，（p.s，似乎其它文章也没多写。。。">12行代码给Wordpress主题挂上AJAX (35)</a></p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.28.10:25.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/974.html" title="网上很多都在谈如何关闭WP2.6的修订记录保存功能。想必已经有很多WP爱好">Wordpress Tips：如何使用自动保存的修订记录 (8)</a></p><p><i>2008.07.27.12:02.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/973.html" title="自2.5起，WP提供了在线编辑时的自动保存功能。自然也是有利有弊。弊么，">Wordpress Hacks：如何管理WP自动保存功能 (10)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2008.07.16.12:15.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/954.html" title="升级至2.6后，除了插件管理页的布局更改外，似乎还没注意到其它显著的变">启用WP2.6 Turbo功能Step by Step (10)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/966.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/966.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>启用WP2.6 Turbo功能Step by Step</title>
		<link>http://www.thinkagain.cn/archives/954.html</link>
		<comments>http://www.thinkagain.cn/archives/954.html#comments</comments>
		<pubDate>Tue, 15 Jul 2008 16:03:30 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Turbo]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/?p=954</guid>
		<description><![CDATA[升级至2.6后，除了插件管理页的布局更改外，似乎还没注意到其它显著的变化。然则在后台的首页，发现多了个Turbo按钮，如下图:
wp2.6内置加速功能？还是涡轮增压？怎么像NSF里面的改装车，... ]]></description>
			<content:encoded><![CDATA[<p>升级至2.6后，除了插件管理页的布局更改外，似乎还没注意到其它显著的变化。然则在后台的首页，发现多了个Turbo按钮，如下图:</p>
<p><a class="thickbox" title="点击Turbo" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807161.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="129" alt="点击Turbo" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807161-thumb.jpg" width="327" border="0" /></a> </p>
<p>wp2.6内置加速功能？还是涡轮增压？怎么像NSF里面的改装车，弄个斯巴鲁(Subaru)来飙飙，所谓改装车是穷人跑车嘛。p.s，实际上改装车要花不少大洋的，但和同样性能的原装名牌跑车相比，还是便宜很多的。然而，即使在日本，引擎之类的改装也是违法的。</p>
<p>如何给WP提速？疑问之余，赶紧随我按下这个按钮来探个究竟。按下按钮后，会出现如下窗口：</p>
<p><a class="thickbox" title="点击Install" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807162.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="274" alt="点击Install" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807162-thumb.jpg" width="400" border="0" /></a> </p>
<p>答案马上就被揭开了，想要涡轮增压，哪能没有安齿轮。原来是利用Google Gear 来实现此功能。但要实现此功能，需先安装Google Gear。点击Install Now开始安装Gear。</p>
<p><a class="thickbox" title="Install Gears" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807163.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="167" alt="Install Gears" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807163-thumb.jpg" width="400" border="0" /></a> </p>
<p>一路点击下去，我点点点。</p>
<p><a class="thickbox" title="一路点下去" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807164.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="247" alt="一路点点点" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807164-thumb.jpg" width="400" border="0" /></a> </p>
<p>将googlegearsetup.exe下载下来。我是用FF3.0下的。程序只需下载安装一次就可以。然而在不同浏览器实现wp的提速，需分别激活该功能。下面会谈到。</p>
<p><a class="thickbox" title="下载安装程序" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807165.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="252" alt="下载安装文件" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807165-thumb.jpg" width="400" border="0" /></a>&#160;</p>
<p>开始安装Gear。</p>
<p><a class="thickbox" title="安装Google Gears" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807166.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="142" alt="安装Google Gears" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807166-thumb.jpg" width="400" border="0" /></a> </p>
<p>安装后提示重启浏览器。</p>
<p><a class="thickbox" title="提示重启浏览器" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/2008071671.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="142" alt="提示重启浏览器" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807167-thumb.jpg" width="400" border="0" /></a> </p>
<p>重启浏览器后，这是还未开启WP的Turbo功能。需再次登陆到WP后台，再次点击Turbo按钮，然后在弹出的窗口中，点击Enable Gears，别急，还没完呢。</p>
<p><a class="thickbox" title="激活Gears" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807168.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="273" alt="激活Gears" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807168-thumb.jpg" width="400" border="0" /></a> </p>
<p>会出现一个安全提示，如下图中提示，是否同意此站点启用Google Gears。这不废话么，要不我费这么大劲来干吗。点击Allow。</p>
<p><a class="thickbox" title="点击Allow启用WP的Gears" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807169.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="270" alt="点击Allow" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/200807169-thumb.jpg" width="368" border="0" /></a> </p>
<p>哇噻，竟然要下载211个文件，还好我的网速还算可以，2-3min搞定。</p>
<p><a class="thickbox" title="211工程" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/2008071610.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="273" alt="211工程" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/2008071610-thumb.jpg" width="400" border="0" /></a> </p>
<p>最后点击Close，直到此时，我的Firefox3.0才会自动在浏览<a href="http://www.thinkagain.cn">www.thinkagain.cn</a>时自动启用Google Gears。</p>
<p><a class="thickbox" title="终于搞定FF，接着下载IE的211" href="http://www.thinkagain.cn/wp-content/uploads/2008/07/2008071611.jpg"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="272" alt="终于搞定FF，接着下载IE的211" src="http://www.thinkagain.cn/wp-content/uploads/2008/07/2008071611-thumb.jpg" width="400" border="0" /></a> </p>
<p>这只是为firefox启用WP的Gear而已，如果想在IE中启用Gear的话，需要在ie下登陆到WP后台，然后点击Turbo按钮，接着又要下载211个文件。（211工程）。是有点浪费资源了，为什么Google不能在程序中设置为各种浏览器共享这211个文件呢。这还只是一个WP，若是其它网站需要开启Gear功能，那岂不还要再去下多少个文件？</p>
<p>启用Gear后，没有用专用工具去测试下网站打开速度的变化，但据说Gear会自动将网站的脚本，css，图片等缓存到本地，理论上会提速的。但不知道在用户想重新载入页面时，在浏览器下，通常是按Ctrl+F5来实现的，Gear用如何处理？</p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/954.html#comments">评论10:</a></p><p><strong>10.</strong><i>2008.07.29.10:14.am</i>.&nbsp;<a href="http://dickeydong.cn/">Dickey</a>: 很详细的步骤！
不过正因如此，我决定还是不安装了 ^_^</p><p><strong>9.</strong><i>2008.07.24.3:31.pm</i>.&nbsp;<a href="http://www.bbon.cn">菠菜</a>: 等会也装上试试。</p><p><strong>8.</strong><i>2008.07.20.10:16.am</i>.&nbsp;<a href="http://3284265.cn/">shamas</a>: 了解下，不打算安装，因为我一会用IE，一会儿用FF</p><p><strong>7.</strong><i>2008.07.18.8:56.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @牧狼羊: 这个只是后台加速用的。游客是不会被提问到是否启用Google Gears的。</p><p><strong>6.</strong><i>2008.07.18.12:48.am</i>.&nbsp;<a href="http://mlyang.cn">牧狼羊</a>: 昨天我还在群里问呢，这有玩意有用么。
有点疑惑，只需自己安装吧？游客访问本站时，不会询问是否安装这些.exe吧？</p><p><strong>5.</strong><i>2008.07.16.12:35.pm</i>.&nbsp;<a href="http://genmicha.cn">Chada</a>: 最近Gear很火，但好像用上的人并不多。</p><p><strong>4.</strong><i>2008.07.16.10:04.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To ddkk3000: 刚才搜索了下的确有一款花儿开了写的wp-turbo插件。有兴趣可以安装来试试看。
To 老N：这种类型的博文比较简单，说白了，只是贴图而已，没有什么技术含量的。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p><p><strong>3.</strong><i>2008.07.16.9:28.am</i>.&nbsp;<a href="http://neolee.cn">老N</a>: 啊呀，慢了，本来我也想写这个的……你写的好仔细哦，只是不知道能不能真的有加速噶。
PS：@yacca 怎么前台加速啊？</p><p><strong>2.</strong><i>2008.07.16.2:14.am</i>.&nbsp;<a href="http://www.eemir3.com">Yacca</a>: gear可以对前台加速滴...打开页面到前台 然后启用gear...</p><p><strong>1.</strong><i>2008.07.16.1:21.am</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: 呵呵，好像花儿开了，还有一款前台加速插件。</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.12.19.12:20.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/1030.html" title=" 有段时间没有写些技术类的文章了，（p.s，似乎其它文章也没多写。。。">12行代码给Wordpress主题挂上AJAX (35)</a></p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.29.9:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/975.html" title="本文将继续来探讨Wordpress数据库查询的相关话题。文一里，我们知道了WP各">Wordpress数据库查询三板斧之三:如何查看WP数据库查询的具体内容 (7)</a></p><p><i>2008.07.28.10:25.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/974.html" title="网上很多都在谈如何关闭WP2.6的修订记录保存功能。想必已经有很多WP爱好">Wordpress Tips：如何使用自动保存的修订记录 (8)</a></p><p><i>2008.07.27.12:02.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/973.html" title="自2.5起，WP提供了在线编辑时的自动保存功能。自然也是有利有弊。弊么，">Wordpress Hacks：如何管理WP自动保存功能 (10)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2008.07.25.1:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/969.html" title="Updated: 2008-07-26，更新Hook代码。  续上文，通过Wordpress基准页面数据库查询">Wordpress数据库查询三板斧之二:如何减少WP数据库查询次数和提高运行效率 (12)</a></p><p><i>2008.07.20.8:12.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/966.html" title="看了下面这张抓图，你就知道我为什么要做这个统计了。  
   昨晚上在DH的">Wordpress数据库查询三板斧之一:WP基准页面数据库查询次数统计 (12)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/954.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/954.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>WordPress Tips：如何打造WP博客的镜像？</title>
		<link>http://www.thinkagain.cn/archives/915.html</link>
		<comments>http://www.thinkagain.cn/archives/915.html#comments</comments>
		<pubDate>Mon, 05 May 2008 15:05:39 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/?p=915</guid>
		<description><![CDATA[在Wordpress中文论坛上曾看到一网友的帖子，讨论如何建立博客镜像的问题。要求不同地址的WP博客可以显示同样内容，其中一个博客负责帖子的管理，而镜像博客只负责内容输出。既然要求是镜... ]]></description>
			<content:encoded><![CDATA[<p>在Wordpress中文论坛上曾看到<a href="http://wordpress.org.cn/thread-12784-2-2.html" target="_blank">一网友的帖子</a>，讨论如何建立博客镜像的问题。要求不同地址的WP博客可以显示同样内容，其中一个博客负责帖子的管理，而镜像博客只负责内容输出。既然要求是镜像，所有内容都需自动完成，所以利用Live Writer等编辑软件分开发布等手法都不属于讨论范围之内。稍微分析一下，实现博客镜像并非不可能，其中涉及二个方面的问题。</p>
<p>一是数据库问题。因为Wordpress的主要内容和配置都放置在数据库内，而页面内容都是动态查询数据库生成的。所以只要能够共享到数据库。镜像问题就可以解决了。</p>
<p>二是永久链接问题。因为主博客和镜像博客的地址是不一样的，所以要求Wordpress博客内的文章，目录，页面等浏览用的永久链接都是根据各自的地址动态生成的。而正因为WP的链接是动态生成的特性，如果能有效利用的话，此问题也就不再是问题了。</p>
<p>我个人对建立博客镜像并不以为然，然而作为WP的Fan，从技术方面探讨其可行性倒是蛮有兴趣。在论坛上看此讨论后，我在本地做了个测试，结果发现，仅需简单地利用wp-config.php对相关选项定义后，完全可以实现二个博客之间的同步。下文中将以主博客和镜像博客用以区分二个博客。</p>
<p><strong>前提</strong></p>
<p>根据上面分析的二个方面，要实现镜像，假设下列前提都必须得以满足。</p>
<p>1. 数据库可以共享。镜像博客必须共享主博客的数据库，所以在wp-config.php中，二者对应的数据库名，帐号和密码必须完全一致。如果镜像博客和主博客位于同一主机上的话，也不存在数据库地址的问题了，（通常都为localhost）。若二者位于不同主机，<u><strong>主博客的数据库必须支持远程登录</strong></u>，否则的话就无法实现镜像。</p>
<p>2.为了保持一致，<strong><u>镜像博客的wordpress目录结构和文件必须完全和主博客一致</u></strong>。即模板文件，插件文件以及.htacess文件必须全部一样。但因为WP是用绝对地址来设置文章中图片和附件等，所以镜像文件可以不需要建立那些在主博客中保存图片或附件的目录。通常是\wp-content\uploads。</p>
<p><strong>步骤</strong></p>
<p>1. 建立镜像博客，将wp文件上传到镜像博客的wp目录，然后将主博客中使用的模板以及插件分别上传到镜像博客的相关目录下。注意，目录结构和模板插件文件必须相同。我是用xampp搭建本地服务器，然后在本地调试的，在本地下分别建立了wp251和mirror目录，使用wp官方2.5.1版程序。前者的url为：<a href="http://localhost/wp251">http://localhost/wp251</a>，设定为主博客。后者url为：<a href="http://localhost/mirror">http://localhost/mirror</a>，作为镜像博客。</p>
<p>用phpmyadmin建立一个数据库wp251，并将现有<a href="http://www.thinkagain.cn" target="_blank">ThinkAgain</a>博客的数据备份导入。</p>
<p>2. 设置wp-config.php</p>
<p>用文本编辑软件如notepad++打开主博客wp251的wp-config.php，设定其数据库参数和定义wp和博客的绝对地址。如下图，点击可查看大图：</p>
<p><a title="主博客wp-config.php部分内容" class="thickbox" href="http://www.thinkagain.cn/wp-content/uploads/2008/05/wp-config_for_main.jpg" target="_blank"><img height="193" alt="主博客wp-config.php部分内容" src="http://www.thinkagain.cn/wp-content/uploads/2008/05/wp-config_for_main.jpg" width="400"/></a> </p>
<p>设定主博客的数据库为wp251，用户名和密码为root和123456，定义了主博客的wp安装目录的绝对地址（WP_HOME）为http://localhost/wp251；博客的地址（WP_SITEURL）为http://localhost/wp251。<u>注：主博客可不定义wp地址和博客地址。</u></p>
<p>接着编辑镜像博客mirror的wp-config.php，如下图：</p>
<p><a title="镜像博客的wp-config.php部分内容" class="thickbox" href="http://www.thinkagain.cn/wp-content/uploads/2008/05/wp-config_for_mirror.jpg" target="_blank"><img height="193" alt="镜像博客的wp-config.php部分内容" src="http://www.thinkagain.cn/wp-content/uploads/2008/05/wp-config_for_mirror.jpg" width="400"/></a></p>
<p>可以看出，该wp-config.php将镜像博客的数据库设定为和主博客一样，均为wp251，用户名和密码为root和123456。也就是说镜像博客将共享使用主博客的数据库，这是问题一的解决方法。</p>
<p>但注意定义了镜像博客的wp地址为http://localhost/mirror；博客的地址为http://localhost/mirror。这是其不同之处。由于WP_HOME和WP_SITEURL是全局变量，这样即使数据库中的定义的WP安装和博客地址为http://localhost/wp251，而Wordpress在运行中将会使用http://localhost/mirror来生成永久链接。这样就解决了问题二。</p>
<p>通过wp-config.php指定二者的位置后，在后台的设置页面可以发现，这二个选项将会以灰色显示，无法编辑。</p>
<p><a title="镜像博客后台设置页面"  class="thickbox" href="http://www.thinkagain.cn/wp-content/uploads/2008/05/location.jpg" target="_blank"><img height="69" alt="镜像博客后台" src="http://www.thinkagain.cn/wp-content/uploads/2008/05/location.jpg" width="400"/></a></p>
<p>p.s，wp安装目录和博客目录分别被保存在数据库中wp_options表的第40项，在wp_options第1项。</p>
<p>3.更新.htacess文件</p>
<p>即使已经将主博客的.htacess上传到镜像博客的wp根目录下，仍需要到镜像博客的后台<u>重新更新</u>下永久链接。注，无需修改链接格式，仅点击更新按钮即可。</p>
<p>4.查看效果</p>
<p>分别打开主博客或镜像博客的页面，对照下面2个抓图，可以看到二者界面和内容完全一致。但地址和链接等是不一样的。图中红色方框处。</p>
<p><a title="主博客抓图" class="thickbox" href="http://www.thinkagain.cn/wp-content/uploads/2008/05/main.jpg" target="_blank"><img height="288" alt="主博客抓图" src="http://www.thinkagain.cn/wp-content/uploads/2008/05/main.jpg" width="400"/></a> </p>
<p>主博客抓图</p>
<p><a title="镜像博客抓图" class="thickbox" href="http://www.thinkagain.cn/wp-content/uploads/2008/05/mirror.jpg" target="_blank"><img height="288" alt="镜像博客抓图" src="http://www.thinkagain.cn/wp-content/uploads/2008/05/mirror.jpg" width="400"/></a> </p>
<p>镜像博客抓图</p>
<p>只要在镜像博客\wp-content\plugins下上传有相同插件。镜像博客也可以完全正常使用插件。上图右边红色方框处是插件生成的代码，这个是我的wp_addbookmarks插件生成的。新添加了半透明的css效果。</p>
<p>到此为止，二个网站已经基本实现同步了。无论是在线或者利用离线编辑软件如live writer等往主博客发表文章后，镜像博客将会立即输出同样内容。因为它们共享同一个数据库来输出内容的。</p>
<p>可以在主博客管理博客的设置，因为共享数据库，<u>所以所做的设置更改也会立即在镜像博客上有效。如果涉及文件修改等，请务必修改镜像博客中的相应文件</u>。</p>
<p><strong>讨论-可能存在的问题</strong></p>
<p>即使成功地将二个博客同步，但仍可能存在些问题。主要为插件方面的兼容性问题。因为插件的涉及面太广，所以我没有去测试过，只能在这里提出一些来互相探讨。</p>
<p>1. 一些涉及永久链接管理的插件，如链接转向，或自定义链接等插件可能无法正常运行在镜像博客上。</p>
<p>2. 博客的统计问题，涉及博客统计的插件，如postview等，将会同时统计二个博客的页面浏览状态，所以在页面显示的浏览量等为主博客和镜像博客的浏览量的总和。</p>
<p>3. 涉及数据库读写或管理的插件可能会不正常。按理来说，虽然镜像博客的插件在运行中会往数据库中写东西不会影响到主博客的运行，但是要注意，如果往数据库内写入含有<u>站点永久链接</u>的内容，那么将会出现问题。因为二个站点的永久链接是不一样的。而数据库内使用同样的永久链接，会造成链接指向絮乱。</p>
<p>4.RSS输出问题，二个博客的rss内容虽然一样，但是需注意主博客和镜像博客的wordpress默认的输出feed地址是不一样的。所以如果在模板中调用wp自带函数用于rss订阅地址输出的话，可能会导致分散了订阅者。这个问题可以通过整合feed地址来解决。将主博客的feed地址提交给feed管理的站点，如feedburner或feedsky，然后在模板中只放置feed管理站点提供的整合后feed地址就可以了。</p>
<p>本文是我根据本地测试的结果总结出来的。用于抛砖引玉，实际建立远程镜像的步骤大同小异，但涉及具体的问题，如插件等，需要根据自己的<u><strong>实际情况</strong></u>而定后再分析解决。为此，建议先在本地测试下，然后再做定夺。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' />  </p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/915.html#comments">评论18:</a></p><p><strong>18.</strong><i>2011.12.10.8:32.pm</i>.&nbsp;<a href="http://wonon.net/?p=888033">WonOn Net &raquo; 如何打造WP博客的镜像？（转载）</a>: [...] 1. 一些涉及永久链接管理的插件，如链接转向，或自定义链接等插件可能无法正常运行在镜像博客上。  [...]</p><p><strong>17.</strong><i>2011.02.10.11:19.pm</i>.&nbsp;<a href="http://blog.wonon.net/?p=888033">WonOn Net &raquo; 如何打造WP博客的镜像？（转载）</a>: [...] 原文链接：http://www.thinkagain.cn/archives/915.html [...]</p><p><strong>16.</strong><i>2010.02.09.8:48.pm</i>.&nbsp;<a href="http://tyzyf.tk/">ZHu</a>: 我的免费空间又挂掉了，所以我觉得博客镜像很重要，但是MySql数据库总是不能远程调用，无法解决。
子与你提到的文章中固定链接的问题，可以用php变量来代替，url中的网站部分，当然，需要插件的支持，因为文章中的php代码会被注释掉的。</p><p><strong>15.</strong><i>2009.03.29.2:10.pm</i>.&nbsp;<a href="http://www.mtyyq.cn">姬良</a>: 咦··
还是有难度··</p><p><strong>14.</strong><i>2008.11.14.6:12.am</i>.&nbsp;<a href="http://wow-rebates.com">rebates</a>: 我是用本地实现的。主要是解决空间IP被封问题
数据库同一个，PHP则放到两个空间上，两个空间都绑同一个域名。
本地解析到能访问的空间，更新时被封IP那个空间也及时更新了</p><p><strong>13.</strong><i>2008.06.23.10:40.pm</i>.&nbsp;<a href="http://hkhpc.com">HK</a>: 看了但是还是不太理解！</p><p><strong>12.</strong><i>2008.06.03.4:18.pm</i>.&nbsp;<a href="http://www.pantao.name">魑魅魍魉</a>: 我觉得我的方法还行，就是写一个插件，这个插件的功能就像Live Writer一样的，在两个博客都安装这个插件，不管哪一个博客发布新文章或者有新留言，博客除了将数据存入自己的数据库之外，还通过API请求将数据同时写入另一个博客， 这就应该能达到完全镜像</p><p><strong>11.</strong><i>2008.05.21.11:52.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To zhang: 据网友9NPC留言，现在很多空间商提供mysql镜像，如果有这样服务的话，数据库之间同步应该就可以实现。不过，个人没尝试过。对于个人博客而言，镜像并不是很需要的。</p><p><strong>10.</strong><i>2008.05.21.9:40.am</i>.&nbsp;<a href="http://zhiqiang.org/blog/">zhang</a>: 两个数据库之间同步不知道可不可以做。</p><p><strong>9.</strong><i>2008.05.18.2:34.pm</i>.&nbsp;<a href="http://zz.neekey.com">neekey</a>: 恐怕大多数想做镜像的都不是在同一个服务器，
最好写一个程序定时对主博客feed进行内容抓取后输出比较好</p><p><strong>8.</strong><i>2008.05.10.9:11.pm</i>.&nbsp;peterzsk: 镜像会不会对搜索引擎产生不良影响？</p><p><strong>7.</strong><i>2008.05.08.5:31.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To patrick: 是通过thickbox来实现的。thickbox代码是自行添加到模板内。具体thickbox的使用可以参考：http://jquery.com/demo/thickbox/  <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' /> </p><p><strong>6.</strong><i>2008.05.08.12:55.pm</i>.&nbsp;patrick: 博主你好！非常喜欢你独立日志页面，文章最下面的FeedMe效果，不知道是如何制作的，是插件实现么？还是直接使用thickbox，我是新手，如果你不介意的话，可否把你的Emial个给我？谢谢！~~</p><p><strong>5.</strong><i>2008.05.07.2:31.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: mysql也放在一个地方，这样的wp镜像，我以为就只是装酷而已了（还不是一个崩溃全完蛋，相当于只有一个），呵呵。可以用mysql的镜像同步功能，放在不同的地方，这个很多虚拟主机商似乎都有提供（现在流行cache啊）。</p><p><strong>4.</strong><i>2008.05.07.7:45.am</i>.&nbsp;<a href="http://my.donews.com/koomi/2008/05/07/links-for-2008-05-06/">酷米小客 - 每日网摘 &raquo; Blog Archive &raquo; links for 2008-05-06</a>: [...] Wordpress Hacks：如何打造WP博客的镜像？ [...]</p><p><strong>3.</strong><i>2008.05.06.4:45.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To 9NPC，同意此观点。注意，如果镜像mysql的地址不一样的话，需在wp-config.php中明确设置。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p><p><strong>2.</strong><i>2008.05.06.11:48.am</i>.&nbsp;<a href="http://www.9npc.com/">9NPC</a>: 其實如果用MYSQL本身的鏡像功能，也可以做到數據庫也分離開。只是要求鏡像和主機之間的通訊正常，而且擁有自己的主機，一般租用的虛擬主機都不能手動去設置MYSQL的參數。</p><p><strong>1.</strong><i>2008.05.06.11:30.am</i>.&nbsp;<a href="http://mlyang.cn">牧狼羊</a>: 上课时在手机上看到这篇文章，回来后意犹未尽，用电脑又重新看了一遍，很不错。</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.12.19.12:20.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/1030.html" title=" 有段时间没有写些技术类的文章了，（p.s，似乎其它文章也没多写。。。">12行代码给Wordpress主题挂上AJAX (35)</a></p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.29.9:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/975.html" title="本文将继续来探讨Wordpress数据库查询的相关话题。文一里，我们知道了WP各">Wordpress数据库查询三板斧之三:如何查看WP数据库查询的具体内容 (7)</a></p><p><i>2008.07.28.10:25.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/974.html" title="网上很多都在谈如何关闭WP2.6的修订记录保存功能。想必已经有很多WP爱好">Wordpress Tips：如何使用自动保存的修订记录 (8)</a></p><p><i>2008.07.27.12:02.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/973.html" title="自2.5起，WP提供了在线编辑时的自动保存功能。自然也是有利有弊。弊么，">Wordpress Hacks：如何管理WP自动保存功能 (10)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2008.07.25.1:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/969.html" title="Updated: 2008-07-26，更新Hook代码。  续上文，通过Wordpress基准页面数据库查询">Wordpress数据库查询三板斧之二:如何减少WP数据库查询次数和提高运行效率 (12)</a></p><p><i>2008.07.20.8:12.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/966.html" title="看了下面这张抓图，你就知道我为什么要做这个统计了。  
   昨晚上在DH的">Wordpress数据库查询三板斧之一:WP基准页面数据库查询次数统计 (12)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/915.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/915.html/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>WordPress Tips:如何使用WP2.5内置的Gravatar</title>
		<link>http://www.thinkagain.cn/archives/904.html</link>
		<comments>http://www.thinkagain.cn/archives/904.html#comments</comments>
		<pubDate>Mon, 31 Mar 2008 07:26:59 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Gravatar]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/?p=904</guid>
		<description><![CDATA[昨日在后台看到WP2.5发布之后，紧接着就到WP官方网站去下载了2.5版。除了焕然一新的后台界面外，在comment管理页面下竟然发现WP能显示Gravatar的头像了，换句话说，既然能显示Gravatar，说明WP已... ]]></description>
			<content:encoded><![CDATA[<p><img style="margin-right:5px" alt="Gravatar" src="http://www.thinkagain.cn/wp-content/uploads/2008/03/gravatar_logo.gif" align="left"/>昨日在后台看到WP2.5发布之后，紧接着就到WP官方网站去下载了2.5版。除了焕然一新的后台界面外，在comment管理页面下竟然发现WP能显示Gravatar的头像了，换句话说，既然能显示Gravatar，说明WP已经提供了显示Gravatar的函数了。但在WP官网的Template Tag下面却没有发现和Gravatar相关的函数。</p>
<p>于是在后台文件中查询后，终于在wp-includes目录下的pluggable.php发现找到Gravatar图像的定义函数(官方英文版1217行)：</p>
<blockquote>
<p><span style="color: blue">function</span> get_avatar( <span style="color: blue">$id_or_email, $size = &#8217;96&#8242;, $default = &#8221; </span>) </p>
</blockquote>
<p>&nbsp;</p>
<p>附带三个参数使用如下：</p>
<blockquote><p>$id_or_email：用于识别用户的id或email；</p>
<p>$size：头像大小，默认为96；</p>
<p>$default：如果用户没有定义Gravatar头像时，显示的默认头像图标地址。</p>
</blockquote>
<p>&nbsp;</p>
<p>如果未指定默认头像的显示地址，则将显示：</p>
<p><img alt="gravatar" src="http://www.thinkagain.cn/wp-content/uploads/2008/03/gravatar.jpg"/></p>
<p>&nbsp;</p>
<p>该语句输出的html代码为：</p>
<blockquote><p><span style="color: #0000ff">&lt;</span><span style="color: #800000">img</span> <span style="color: #ff0000">width</span>=<span style="color: #0000ff">&#8220;96&#8243;</span> <span style="color: #ff0000">height</span>=<span style="color: #0000ff">&#8220;96&#8243;</span> <span style="color: #ff0000">class</span>=<span style="color: #0000ff">&#8220;avatar avatar-96&#8243;</span> <span style="color: #ff0000">src</span>=<span style="color: #0000ff"><a href="http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96">http://www.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=96</a></span> <span style="color: #ff0000">alt</span>=<span style="color: #0000ff">&#8220;&#8221;</span><span style="color: #0000ff">/&gt;</span></p></blockquote>
<p>&nbsp;</p>
<p>为此，从2.5版起，用户可以不用再依靠第三方插件，直接在评论模板(comments.php)中加入该函数的调用代码用来显示评论者的Gravatar头像。以本站为例，介绍下该函数的使用：</p>
<blockquote>
<p><span style="color: #0000ff">&lt;?</span>php echo get_avatar( $email, $size = &#8217;32&#8242;, $default = &#8221; ); <span style="color: #0000ff">?&gt;</span></p>
</blockquote>
<p>&nbsp;</p>
<p>$email是评论者的email地址，可以在comments.php的&lt;?php foreach ($comments as $comment) : ?&gt;语句后面，增加$email变量的赋值语句，$email=$comment-&gt;comment_author_email来获取评论者email地址。</p>
<p>$size变量定义了图像大小为32px。</p>
<p>注意，使用时，需通过<strong>echo</strong>函数来输出文本的。</p>
<p>在下面发表个评论，您就可以看见显示效果了。</p>
<p>上述介绍的是该函数完整的调用方法。还有一种简单的调用法，可WP2.5的默认模板的comments.php 第30行，其使用了</p>
<blockquote><p>
<span style="color: #0000ff">&lt;?</span>php <a style="color: #0000ff" href="http://www.php.net/echo">echo</a> get_avatar( $comment, 32 ); <span style="color: #0000ff">?&gt;</span>
</p></blockquote>
<p>&nbsp;</p>
<p>来直接输出Gravatar图像。无论用那种方法，务必注意，该函数的调用须放在&lt;?php foreach ($comments as $comment) : ?&gt;语句后，否则会出错。</p>
<p>当然，如果想正确显示Gravatar的话，<strong>前提必须是评论者必须l在</strong><a title="http://www.gravatar.com/" href="http://www.gravatar.com/" target="_blank"><strong>Gravatar</strong></a><strong>上注册并提交了个性化头像。</strong></p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/904.html#comments">评论21:</a></p><p><strong>21.</strong><i>2008.07.23.3:57.pm</i>.&nbsp;<a href="http://dodofly.cn">dodofly</a>: 我来做测试</p><p><strong>20.</strong><i>2008.06.11.2:37.pm</i>.&nbsp;<a href="http://lihuazhi.com">WalltzLee</a>: 呵呵，gravatar后来我自己弄好了</p><p><strong>19.</strong><i>2008.06.08.9:53.pm</i>.&nbsp;<a href="http://lihuazhi.com">WalltzLee</a>: 我用的就是默认的主题，就是用下面这个函数的

但是用wp_gravatar插件却能显示出，怎么回事呢？</p><p><strong>18.</strong><i>2008.06.08.9:51.pm</i>.&nbsp;<a href="http://lihuazhi.com">WalltzLee</a>: 唉，我自己的网站显示不出来</p><p><strong>17.</strong><i>2008.06.01.11:26.am</i>.&nbsp;<a href="http://www.yoyoyaya.cn">悠悠吖吖</a>: 看看究竟是允许访客自由选择头像 还是系统随机提供的</p><p><strong>16.</strong><i>2008.05.18.2:55.pm</i>.&nbsp;不曾有过: 看看我的头像！</p><p><strong>15.</strong><i>2008.05.18.2:53.pm</i>.&nbsp;不曾有过: 凑个热闹！</p><p><strong>14.</strong><i>2008.05.16.5:54.pm</i>.&nbsp;peterzsk: 头像啊头像</p><p><strong>13.</strong><i>2008.05.16.2:38.pm</i>.&nbsp;<a href="http://www.maqingxi.com">maqingxi</a>: 我也来秀下我的头像，呵呵。</p><p><strong>12.</strong><i>2008.05.10.5:58.pm</i>.&nbsp;<a href="http://amoy.czm.cn/cittolang">limkianhui</a>: 谢谢。我也使用了这个了。</p><p><strong>11.</strong><i>2008.04.24.3:57.pm</i>.&nbsp;<a href="http://kof2002.vicp.net/wp/?p=13">梦雨部落格 &raquo; blog archive &raquo; Wordpress Hacks:如何使用WP2.5内置的Gravatar</a>: [...] 昨日在后台看到WP2.5发布之后，紧接着就到WP官方网站去下载了2.5版。除了焕然一新的后台界面外，在comment管理页面下竟然发现WP能显示Gravatar的头像了，换句话说，既然能显示Gravatar，说明WP已经提供了显示Gravatar的函数了。但在WP官网的Template Tag下面却没有发现和Gravatar相关的函数。  [...]</p><p><strong>10.</strong><i>2008.04.19.4:37.pm</i>.&nbsp;<a href="http://www.jokercc.cn">joker</a>: 搞定了，tks，大哥。</p><p><strong>9.</strong><i>2008.04.12.1:35.pm</i>.&nbsp;<a href="http://www.newstanley.com/wordpress">Stanley</a>: 用上了 谢谢</p><p><strong>8.</strong><i>2008.04.10.11:33.am</i>.&nbsp;<a href="http://www.lording.cn">lording</a>: 我也试试看</p><p><strong>7.</strong><i>2008.04.04.4:56.pm</i>.&nbsp;<a href="http://www.aftertown.cn/2008/04/wordpress-hacks-gravatar/">城市@后 &raquo; Wordpress Hacks:如何使用WP2.5内置的Gravatar</a>: [...] 语句后，否则会出错。 当然，如果想正确显示Gravatar的话，前提必须是评论者必须l在Gravatar上注册并提交了个性化头像。 【参考文献：（作者ThinkAgain） 点击查看】 [...]</p><p><strong>6.</strong><i>2008.04.02.6:32.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: 新版wp后台把我吓傻了…………</p><p><strong>5.</strong><i>2008.04.01.1:30.pm</i>.&nbsp;<a href="http://www.sunnyfly.com/blog">Bruce</a>: 呵呵，很不错的文章，我也正在纳闷儿呢。</p><p><strong>4.</strong><i>2008.03.31.10:57.pm</i>.&nbsp;<a href="http://demo.blogoor.com/archives/538.html">Wordpress Hacks:如何使用WP2.5内置的Gravatar | wordpress | 乱七∩_∩八糟</a>: [...] Copyright 2008 | Think Again | 原文链接 | 评论 [...]</p><p><strong>3.</strong><i>2008.03.31.7:55.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: Not Bad. Red smily. <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' /> </p><p><strong>2.</strong><i>2008.03.31.7:40.pm</i>.&nbsp;<a href="http://realaxt.com/">Jim</a>: 试下我的头像   <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_rolleyes.gif' alt=':roll:' class='wp-smiley' /> </p><p><strong>1.</strong><i>2008.03.31.3:55.pm</i>.&nbsp;<a href="http://ecvip.org/">oxygen</a>: 呵呵，还真把它研究出来了 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' /> </p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.12.19.12:20.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/1030.html" title=" 有段时间没有写些技术类的文章了，（p.s，似乎其它文章也没多写。。。">12行代码给Wordpress主题挂上AJAX (35)</a></p><p><i>2008.12.07.9:51.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/1029.html" title=" 这一阵子，Google Friend Connect似乎闹得挺热乎的。周围的网友博客们纷纷在">Hot friends新增支持用户自定义头像显示 (65)</a></p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.29.9:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/975.html" title="本文将继续来探讨Wordpress数据库查询的相关话题。文一里，我们知道了WP各">Wordpress数据库查询三板斧之三:如何查看WP数据库查询的具体内容 (7)</a></p><p><i>2008.07.28.10:25.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/974.html" title="网上很多都在谈如何关闭WP2.6的修订记录保存功能。想必已经有很多WP爱好">Wordpress Tips：如何使用自动保存的修订记录 (8)</a></p><p><i>2008.07.27.12:02.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/973.html" title="自2.5起，WP提供了在线编辑时的自动保存功能。自然也是有利有弊。弊么，">Wordpress Hacks：如何管理WP自动保存功能 (10)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2008.07.25.1:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/969.html" title="Updated: 2008-07-26，更新Hook代码。  续上文，通过Wordpress基准页面数据库查询">Wordpress数据库查询三板斧之二:如何减少WP数据库查询次数和提高运行效率 (12)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/904.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/904.html/feed</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>如何使用WordPress内置的分页（Nextpage）功能？</title>
		<link>http://www.thinkagain.cn/archives/888.html</link>
		<comments>http://www.thinkagain.cn/archives/888.html#comments</comments>
		<pubDate>Sat, 08 Dec 2007 14:50:37 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[分页]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/archives/888.html</guid>
		<description><![CDATA[2007-12-09：注，我已经写了一个插件用于含有nextpage或more标签的feed全文输出，详见WordPress插件:whole_feed_output v0.1，为此无需自行修改WP源代码。第4部分的代码修改仅作为参考用。 *********************... ]]></description>
			<content:encoded><![CDATA[<p><strong>2007-12-09：注，我已经写了一个插件用于含有nextpage或more标签的feed全文输出，详见<a href="http://www.thinkagain.cn/archives/889.html">WordPress插件:whole_feed_output v0.1</a>，为此无需自行修改WP源代码</strong>。第4部分的代码修改仅作为参考用。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_wink.gif' alt=':wink:' class='wp-smiley' />   </p>
<p>********************************</p>
<p>看到在论坛上也有一些网友在探讨<a href="http://www.wordpress.org.cn/forums/thread-7615-1-1.html" target="_blank">关于Wordpress文章分页</a>的问题等，而实际上wordpress本身已经内置了文章的分页功能，即通过使用Nextpage标签来将文章分割成多个页面。索性花了点时间好好整理了一下，系统性地写下这篇文章，着重介绍下wordpress内置的nextpage标签分页及相关用法等。望对使用WP的网友有所帮助。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_wink.gif' alt=':wink:' class='wp-smiley' />  。为了测试WP分页，我将此文章分成4页。要阅读全文的话，就慢慢点吧。  <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_cool.gif' alt=':cool:' class='wp-smiley' />   文中涉及代码修改等，<u>均只在2.3和2.3.1中测试通过，敬请注意</u>。本文将包括如下几个部分内容。</p>
<p>先来谈谈nextpage标签的作用及使用方法。</p>
<p><strong>1.nextpage标签的作用及使用方法。</strong></p>
<p>nextpage标签，确切地说是，&lt;!- -nextpage- -&gt;代码，是wordpress内置的用于实现文章分页的一个page标签。您可以在一篇文章中插入多个nextpage标签实现多个分页。在文章中插入该标签后，从文章开头至第一个nextpage标签为文章的第一个分页内容，第一个nextpage标签和第二个nextpage标签之间为文章第二个分页的内容，以此类推，直至文章结束。这一点和more标签不同。</p>
<p>然而，有一点要注意，如果more标签在nextpage标签之前的话，在首页的输出中，还是会被more标签截断的。</p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/888.html#comments">评论52:</a></p><p><strong>52.</strong><i>2011.04.03.7:46.am</i>.&nbsp;<a href="http://kangxiaowei.com/?p=4112">WordPress给单篇文章增加分页功能 &#8211; 四师兄：只为传播一种思想</a>: [...] 先来谈谈nextpage标签的作用及使用方法。&nbsp; 1.nextpage标签的作用及使用方法。 nextpage标签，确切地说是，&lt;!- -nextpage- [...]</p><p><strong>51.</strong><i>2010.10.20.1:52.am</i>.&nbsp;<a href="http://www.yue366.com/archives/133.html">苯小月的多天网 &raquo; wordpress 长文章如何实现分页功能</a>: [...] 略。WordPress长文章分页和如何使用WordPress内置的分页（Nextpage）功能？等等详细的介绍了&lt;!&#8211;nextpage&#8211;&gt;功能，并且据说是不需要插件就能实现。 [...]</p><p><strong>50.</strong><i>2010.05.10.9:45.am</i>.&nbsp;<a href="http://www.yeeones.com">一心而已</a>: 谢谢分享 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> </p><p><strong>49.</strong><i>2010.03.20.8:44.pm</i>.&nbsp;<a href="http://13796432.blog.hexun.com/">马毕</a>: 我的博客欢迎指教http://13796432.blog.hexun.com/</p><p><strong>48.</strong><i>2010.03.16.10:25.pm</i>.&nbsp;<a href="http://www.semdiy.cn/chong/">虫虫博客2009</a>: 博主太有才了 学习了</p><p><strong>47.</strong><i>2010.03.11.1:02.am</i>.&nbsp;cksan: 我跟amy一样，使用2.9.2，没找到more。。。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_cry.gif' alt=':cry:' class='wp-smiley' /> </p><p><strong>46.</strong><i>2010.03.08.3:41.pm</i>.&nbsp;<a href="http://www.buylacostes.com/">lacoste</a>: 嘿嘿~无意间来你的地盘~不错的博文~期待更精彩的~</p><p><strong>45.</strong><i>2010.03.06.11:40.am</i>.&nbsp;<a href="http://zzaza.com/archives/655">天天坊 &raquo; 如何使用Wordpress内置的分页（Nextpage）功能</a>: [...] 原文出处：http://www.thinkagain.cn/archives/888.html [...]</p><p><strong>44.</strong><i>2010.03.04.1:46.pm</i>.&nbsp;<a href="http://www.future.org.cn/zd/">amy</a>: 你好，我在使用 wordpress2.9.2，在网上找了很久关于分页的资料，都不能分，你这个讲得最全面，但是还不能解决问题，wordpress2.9.2的目录结构和你说得不一样，能帮我看下吗？非常感谢！</p><p><strong>43.</strong><i>2010.02.12.9:06.pm</i>.&nbsp;<a href="http://www.khc.name/index.php/2010/02/12/38">KHC&#39;s &raquo; 在文章中添加类似“继续阅读”和“下一页”的按钮</a>: [...] 其实原生的WP中有个nextpage标签，其功能就是实现日志分页，只是被认为的“隐藏”起来了，我们使用不了而已。nextpage标签，确切地说 是，&lt;!- -nextpage- -&gt;代码，是wordpress内置的用于实现文章分页的一个page标签。您可以在一篇文章中插入多个nextpage标签实现多个分页。在文章 中插入该标签后，从文章开头至第一个nextpage标签为文章的第一个分页内容，第一个nextpage标签和第二个nextpage标签之间为文章第 二个分页的内容，以此类推，直至文章结束。这一点和more标签不同。 然而，有一点要注意，如果more标签在nextpage标签之前的话，在首页的输出中，还是会被more标签截断的。哪么如何使用这个代码呢？ [...]</p><p><strong>42.</strong><i>2010.02.11.9:51.pm</i>.&nbsp;<a href="http://kuailedao.org/">快乐岛博客</a>:  <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  方法真好，就是这样看着好费劲啊！</p><p><strong>41.</strong><i>2009.12.14.9:01.pm</i>.&nbsp;<a href="http://www.chenyg.cn/">广辉岁月</a>: 真实不错的办法，wp总给人想象不到的空间！</p><p><strong>40.</strong><i>2009.11.01.11:37.am</i>.&nbsp;<a href="http://www.snowfly.net/?p=16">wordpress上一篇长文章如何分页？ - 雪纷飞</a>: [...] 我是怎么做到的？G到的第一篇是《如何使用Wordpress内置的分页（Nextpage）功能？》它介绍了几种方法。我试了试，我是2.8.4版本的wordpress，上面介绍的方法，都无法实现。不过，这一篇写得很仔细，相信对其它人会有用。然后就是《WordPress如何单日志分页》。就像作者说的： [...]</p><p><strong>39.</strong><i>2009.10.11.10:42.pm</i>.&nbsp;<a href="http://xuefenfei.netai.net/?p=29">一篇长文章如何分页？ - 雪纷飞</a>: [...] &#160;&#160; 我是怎么做到的？G到的第一篇是《如何使用Wordpress内置的分页（Nextpage）功能？》它介绍了几种方法。我试了试，我是2.8.4版本的wordpress，上面介绍的方法，都无法实现。不过，这一篇写得很仔细，相信对其它人会有用。然后就是《WordPress如何单日志分页》。就像作者说的： [...]</p><p><strong>38.</strong><i>2009.09.29.1:18.pm</i>.&nbsp;<a href="http://www.seoask.com.cn">广州seo咨询室</a>: 简单的讲，我用了，但是没显示分页</p><p><strong>37.</strong><i>2009.08.28.8:51.am</i>.&nbsp;<a href="http://feilong.org">飞龙</a>: 我想过用分页，但是与其这样，不过如分日志处理。个中理由不外乎seo角度和相关性问题。</p><p><strong>36.</strong><i>2009.07.31.9:38.am</i>.&nbsp;<a href="http://blog.shuxiong.net">shuxiong</a>: 手动分页太麻烦了~又没有自动分页的呢？</p><p><strong>35.</strong><i>2009.06.05.10:06.pm</i>.&nbsp;<a href="http://www.99xunle.com">cyang</a>: 给个样例就好了</p><p><strong>34.</strong><i>2009.04.25.8:10.pm</i>.&nbsp;<a href="http://xc84.com">小程</a>: 现在用的2.7.1，在tiny_mce_popup中找不到wp_more了。

2.7还可以使用这个分页功能吗？该如何实现呢？</p><p><strong>33.</strong><i>2009.04.25.12:35.am</i>.&nbsp;<a href="http://www.w-link.org.cn/?p=23">老李的草庐 &raquo; Blog Archive &raquo; 如何使用Wordpress内置的分页功能 Nextpage</a>: [...] 默认输出效果为： Pages: 1 2 [...]</p><p><strong>32.</strong><i>2009.03.28.11:34.am</i>.&nbsp;<a href="http://www.mazusys.info/journals/">青鸟</a>: 刚建了WP博客，学习中...</p><p><strong>31.</strong><i>2009.03.26.1:00.pm</i>.&nbsp;<a href="http://www.100daysns.com">Joe Lam</a>: 很好..我會下載看看.!</p><p><strong>30.</strong><i>2009.02.21.2:56.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-90091" rel="nofollow">@琪琪老爸 </a>那您就多来逛逛吧。呵呵。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_biggrin.gif' alt=':grin:' class='wp-smiley' /> </p><p><strong>29.</strong><i>2009.02.20.3:50.pm</i>.&nbsp;<a href="http://www.girlqiqi.cn">琪琪老爸</a>: 呵呵,发现不少需要学习的知识都在你这里可以找到. <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' /> </p><p><strong>28.</strong><i>2008.10.05.11:12.am</i>.&nbsp;<a href="http://seo-dic.com.cn/index.php/archives/969">让WordPress的默认编辑器功能更强大 | 希奥开源</a>: [...] 查看会员 [美丽星点] 的文章列表&nbsp;&nbsp;&nbsp;&nbsp;  上一篇:&nbsp;添加wine源详细步骤   终极改造之一：让默认可视化编辑器支持更多的功能 之前think again《如何使用Wordpress内置的分页功能？- Nextpage》文章中提到如何通过修改wordpress安装目录下的wp-includesjstinymcetiny_mce_config.php文件来添加分页(wp_more)按钮,其实我们完全可以通过一个强大的插件TinyMCE advaced来实现，它是 TinyMCE 的增加版，支持富文本编辑，水平线，图像插入增加，链接插入增加，表情，全屏，语法错误拼写，添加层，打印，查找与替换，添加自定义样式，添加表格，当然这些按钮是可选的，您可以通过：后台管理-&gt;TinyMCE Advanced中通过简单的托拽来添加和删除它的每一个功能模块。  插件名称：TinyMCE advaced 官方网站：http://wordpress.org/extend/plugins/tinymce-advanced/ 项目网站：http://www.laptoptips.ca/projects/tinymce-advanced/ 下载地址：http://downloads.wordpress.org/plugin/tinymce-advanced.3.1.zip [...]</p><p><strong>27.</strong><i>2008.09.25.7:31.pm</i>.&nbsp;<a href="http://haohtml.com/wp/index.php/archives/412">haohtml&#8217;s blog &raquo; Blog Archive &raquo; 如何使用Wordpress内置的分页（Nextpage）功能？</a>: [...] 先来谈谈nextpage标签的作用及使用方法。  [...]</p><p><strong>26.</strong><i>2008.09.16.3:02.pm</i>.&nbsp;<a href="http://www.mb120.com/blog/?p=580">弹指神功 &raquo; Blog Archive &raquo; wordpress 单篇日志实现分页</a>: [...] a.可视化模式输入  [...]</p><p><strong>25.</strong><i>2008.09.14.9:37.am</i>.&nbsp;<a href="http://www.thirdinfo.com/">辐射鱼</a>: 我在本地测试more标签竟然可以在前面，xp环境</p><p><strong>24.</strong><i>2008.09.09.5:01.pm</i>.&nbsp;<a href="http://www.alibuybuy.com/archives/911">互联网的那点事&#8230; &raquo; blog archive &raquo; 技巧：Wordpress单篇日志如何实现分页</a>: [...]     其实原生的WP中有个nextpage标签，其功能就是实现日志分页，只是被认为的“隐藏”起来了，我们使用不了而已。nextpage标签，确切地说是，&lt;!- -nextpage- -&gt;代码，是wordpress内置的用于实现文章分页的一个page标签。您可以在一篇文章中插入多个nextpage标签实现多个分页。在文章中插入该标签后，从文章开头至第一个nextpage标签为文章的第一个分页内容，第一个nextpage标签和第二个nextpage标签之间为文章第二个分页的内容，以此类推，直至文章结束。这一点和more标签不同。 然而，有一点要注意，如果more标签在nextpage标签之前的话，在首页的输出中，还是会被more标签截断的。哪么如何使用这个代码呢？ [...]</p><p><strong>23.</strong><i>2008.08.30.4:08.am</i>.&nbsp;<a href="http://www.cqadmin.net.cn/index.php/archives/99">简单学向上 &raquo; wordpress 单篇日志实现分页</a>: [...] 其实原生的WP中有个nextpage标签，其功能就是实现日志分页，只是被认为的“隐藏”起来了，我们使用不了而已。nextpage标签，确切 地说是，&lt;!- -nextpage- -&gt;代码，是wordpress内置的用于实现文章分页的一个page标签。您可以在一篇文章中插入多个nextpage标签实现多个分页。在文章 中插入该标签后，从文章开头至第一个nextpage标签为文章的第一个分页内容，第一个nextpage标签和第二个nextpage标签之间为文章第 二个分页的内容，以此类推，直至文章结束。这一点和more标签不同。 然而，有一点要注意，如果more标签在nextpage标签之前的话，在首页的输出中，还是会被more标签截断的。哪么如何使用这个代码呢？ [...]</p><p><strong>22.</strong><i>2008.08.28.9:16.am</i>.&nbsp;<a href="http://61.187.251.224:8082/wordpress/?p=106">Wordpress的分页功能 - 杰维智能 一触杰道</a>: [...]     其实原生的WP中有个nextpage标签，其功能就是实现日志分页，只是被认为的“隐藏”起来了，我们使用不了而已。nextpage标签，确切地说是，&lt;!- -nextpage- -&gt;代码，是wordpress内置的用于实现文章分页的一个page标签。您可以在一篇文章中插入多个nextpage标签实现多个分页。在文章中插入该标签后，从文章开头至第一个nextpage标签为文章的第一个分页内容，第一个nextpage标签和第二个nextpage标签之间为文章第二个分页的内容，以此类推，直至文章结束。这一点和more标签不同。 然而，有一点要注意，如果more标签在nextpage标签之前的话，在首页的输出中，还是会被more标签截断的。哪么如何使用这个代码呢？ [...]</p><p><strong>21.</strong><i>2008.08.27.6:09.pm</i>.&nbsp;<a href="http://jiaogen.com/index.php/archives/1669">wordpress 单篇日志实现分页 | Ashley</a>: [...] a.可视化模式输入  [...]</p><p><strong>20.</strong><i>2008.08.09.5:27.pm</i>.&nbsp;<a href="http://www.i1987.cn/wordpress/?p=182">孔雀网官方博客 &raquo; 内容索引 &raquo; wordpress 单篇日志实现分页 - 孔雀网官方博客</a>: [...] a.可视化模式输入  [...]</p><p><strong>19.</strong><i>2008.07.30.11:48.pm</i>.&nbsp;<a href="http://alibm.org">阿里</a>: 添加了了这个函数。没升级到2.6之前都是可以的。我从头到尾又检查了一遍，发现每个步骤都没有出错。现在还没找到问题出在哪。</p><p><strong>18.</strong><i>2008.07.30.6:51.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @阿里: 要实现分页，必须在模板内添加wp_link_pages函数。</p><p><strong>17.</strong><i>2008.07.30.4:22.pm</i>.&nbsp;<a href="http://alibm.org">阿里</a>: 就是按要求做了,无法实现分页效果。</p><p><strong>16.</strong><i>2008.07.30.12:19.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: @阿里: 不大明白你的问题。</p><p><strong>15.</strong><i>2008.07.30.4:29.am</i>.&nbsp;<a href="http://alibm.org">阿里</a>: 2.6后，还可以用吗？为什么加入<code> '<strong>还很长，继续看下一页:</strong> ', 'after' =&gt; '', 'next_or_number' =&gt; 'number')); ?&gt;</code>
而实际上却没有分页效果呢？</p><p><strong>14.</strong><i>2008.07.27.2:13.pm</i>.&nbsp;<a href="http://3284265.cn">shamas</a>: 我用了静态插件后,这个就失效了,</p><p><strong>13.</strong><i>2008.07.01.5:57.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To 鞅猫: 因为这个是wp内置的函数，所以函数本身应该是不会有问题。先禁用下所有插件检查是否是插件冲突造成的。</p><p><strong>12.</strong><i>2008.07.01.4:16.pm</i>.&nbsp;<a href="http://www.icoob.com">鞅猫</a>: 一个很严重的问题...我用了..不行..分两页显示的是一样的文章..
而且第*****页面也是第四页的文章...11，12，13，14，15，16...........................
这么多同样的..不被k才怪
你可以把地址栏的页面数改下看..问题很严重</p><p><strong>11.</strong><i>2008.06.25.8:58.pm</i>.&nbsp;<a href="http://www.kkv88.cn/index.php/2008/06/25/91/">&raquo; wordpress 单篇日志实现分页 - 香烟啤酒</a>: [...]     其实原生的WP中有个nextpage标签，其功能就是实现日志分页，只是被认为的“隐藏”起来了，我们使用不了而已。nextpage标签，确切地说是，&lt;!- -nextpage- -&gt;代码，是wordpress内置的用于实现文章分页的一个page标签。您可以在一篇文章中插入多个nextpage标签实现多个分页。在文章中插入该标签后，从文章开头至第一个nextpage标签为文章的第一个分页内容，第一个nextpage标签和第二个nextpage标签之间为文章第二个分页的内容，以此类推，直至文章结束。这一点和more标签不同。 然而，有一点要注意，如果more标签在nextpage标签之前的话，在首页的输出中，还是会被more标签截断的。哪么如何使用这个代码呢？ [...]</p><p><strong>10.</strong><i>2008.05.06.11:33.am</i>.&nbsp;<a href="http://mlyang.cn">牧狼羊</a>: 真好，这样不用安装插件吧？</p><p><strong>9.</strong><i>2008.03.07.12:58.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To 独木，记得好像WP论坛上已经有你所提到的插件了。也就是提供指定输出固定字数的文章内容。你可以去论坛里搜索下。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' /> </p><p><strong>8.</strong><i>2008.03.06.3:07.pm</i>.&nbsp;<a href="http://www.infoea.com">独木</a>: 博主分享了一个非常棒的文章，我也正是为此事而烦恼，现在终于可以解决分页问题了！
其实并没达到我最想要的结果，我更想不用插件让他自动分页，比如按照一定数量的文字或者行等等，就像一些CMS一样，是不是要求有点高哈，感谢感谢</p><p><strong>7.</strong><i>2008.03.02.11:58.am</i>.&nbsp;<a href="http://www.163share.cn/60">(转)如何使用Wordpress内置的分页功能？- Nextpage - 喜儿: 资源共分享 - 学习|影音|数码|生活|理财分享社区</a>: [...] 看到在论坛上也有一些网友在探讨关于Wordpress文章分页的 问题等，而且很多网友在寻找自动分页的插件。而实际上wordpress本身已经内置了文章的分页功能，即通过使用Nextpage标签来将文章分割成多个页面。手工加入标签虽然麻烦一点点的，但是对于分页的控制比自动分页要强很多。索性花了点时间好好整理了一 下，系统性地写下这篇文章，着重介绍下wordpress内置的nextpage标签分页及相关用法等。望对使用WP的网友有所帮助。  。文中涉及代码修改等，均只在2.3和2.3.1中测试通过，敬请注意。本文将包括如下几个部分内容。  [...]</p><p><strong>6.</strong><i>2008.01.02.9:52.pm</i>.&nbsp;<a href="http://www.a18zhizao.cn/2008/01/02/%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8wordpress%e5%86%85%e7%bd%ae%e7%9a%84%e5%88%86%e9%a1%b5%e5%8a%9f%e8%83%bd-nextpage">A18制造 &raquo; Blog Archive &raquo; 如何使用Wordpress内置的分页功能 Nextpage</a>: [...] Pages: 1 2 [...]</p><p><strong>5.</strong><i>2007.12.28.10:32.am</i>.&nbsp;<a href="http://www.sitemasterkit.com/archives/43">站长工具箱 &raquo; Blog Archive &raquo; (转)如何使用Wordpress内置的分页功能？- Nextpage</a>: [...] 看到在论坛上也有一些网友在探讨关于Wordpress文章分页的 问题等，而且很多网友在寻找自动分页的插件。而实际上wordpress本身已经内置了文章的分页功能，即通过使用Nextpage标签来将文章分割成多个页面。手工加入标签虽然麻烦一点点的，但是对于分页的控制比自动分页要强很多。索性花了点时间好好整理了一 下，系统性地写下这篇文章，着重介绍下wordpress内置的nextpage标签分页及相关用法等。望对使用WP的网友有所帮助。  。文中涉及代码修改等，均只在2.3和2.3.1中测试通过，敬请注意。本文将包括如下几个部分内容。  [...]</p><p><strong>4.</strong><i>2007.12.10.2:09.pm</i>.&nbsp;<a href="http://www.genmicha.cn/">chada</a>: 很有用，以后很长的文章就不用分几篇日志发了。
我换了新主题哦！ <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' />  顺便把广告插上了。</p><p><strong>3.</strong><i>2007.12.09.8:28.am</i>.&nbsp;<a href="http://www.alanoy.cn">Alan</a>: 学习了，厉害 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p><p><strong>2.</strong><i>2007.12.08.11:17.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>:  <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_redface.gif' alt=':oops:' class='wp-smiley' />  什么牛。</p><p><strong>1.</strong><i>2007.12.08.11:11.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: 牛人，又学习了一点， <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2007.10.31.12:42.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/830.html" title="Updated:此问题已经在2.3.3中被修复。
*****************************
前几天，将Wordp">Wordpress Hacks:升级2.3.1可能出现邮件提醒失效的解决方法 (20)</a></p><p><i>2007.10.22.11:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/822.html" title="在wordpress中，默认点击评论者的链接时，会在同一窗口内打开该链接。这在">Wordpress Hacks: 在新窗口中打开评论者链接和no follow属性 (16)</a></p><p><i>2007.09.15.10:41.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/721.html" title="继将CSS修改符合W3C规范后，今天花了点时间，也将模板代码修改完毕，通过">继续修改模板 (4)</a></p><p><i>2007.08.21.8:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/611.html" title="又是一时心血来潮，试用过Wordpress后，想装上Movable Type 4.0玩玩看。于是就">图文介绍如何在本地服务器安装Movable Type 4.0 (15)</a></p><p><i>2007.06.11.3:55.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/189.html" title="由于博客上的图片大部分都是放在Flickr上的，所以Flickr被禁后导致国内朋友">WordPress解决Flickr图片显示方法 (3)</a></p><p><i>2007.04.30.8:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/161.html" title="Widgets是一个可视化Wordpress主题侧边栏编辑插件，用户可以在Wordpress后台主">如何修改代码使主题支持widgets (5)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/888.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/888.html/feed</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
		<item>
		<title>WordPress Hacks:升级2.3.1可能出现邮件提醒失效的解决方法</title>
		<link>http://www.thinkagain.cn/archives/830.html</link>
		<comments>http://www.thinkagain.cn/archives/830.html#comments</comments>
		<pubDate>Wed, 31 Oct 2007 04:42:51 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/archives/830.html</guid>
		<description><![CDATA[前几天，将Wordpress从2.3升级到2.3.1后，发现WP内置的邮件提醒功能失效了。具体表现在为，新评论来的时候，无法邮件提醒，以及wp backup无法定时将数据库备份发送到指定邮箱中等等。相关调用W... ]]></description>
			<content:encoded><![CDATA[<p><strong>Updated:此问题已经在2.3.3中被修复。</strong></p>
<p>*****************************</p>
<p>前几天，将Wordpress从2.3升级到2.3.1后，发现WP内置的邮件提醒功能失效了。具体表现在为，新评论来的时候，无法邮件提醒，以及wp backup无法定时将数据库备份发送到指定邮箱中等等。相关调用WP内置的mail发送功能的插件都无法使用。</p>
<p>曾Wordpress论坛上<a href="http://www.wordpress.org.cn/forums/thread-6726-1-2.html">发帖</a>谈到此问题，遗憾的是，网友建议的方法，都不管用，我曾经在<a href="http://trac.wordpress.org/changeset/6293/tags/2.3.1?old=6293&amp;old_path=tags%2F2.3#file22">WordPress Trac</a>上，对比2.3和2.3.1修改的修改内容，按论坛中建议的方法，一个个将修改的文件下来后，覆盖到2.3版，然后再将修改后的文件覆盖到站上的WP。问题仍然存在。且，在中文论坛上发帖，并没有见网友参与讨论，也没有见其他人对此问题发帖，估计可能还没有几个人有碰到类似的问题。所以姑且称之为，<strong>可能</strong>出现该问题。</p>
<p>在WP的官方论坛上，搜索了一下。找到了一篇类似问题的<a href="http://wordpress.org/support/topic/140882?replies=4">求助帖</a>。可惜，也是无果。(最终的解决方法，嘿嘿，还是我发的。)</p>
<p>对照着Trac上面刊载着的2.3和2.3.1 wp-mail.php的不同处。却不认为，是这些新增的代码造成邮件无法发送。</p>
<p>上午，无意中，看到Peter westwood的一篇文章&#8221;<a href="http://westi.wordpress.com/2007/10/26/wordpress-231-in-detail/">WordPress 2.3.1 in detail</a>&#8220;，里面介绍了2.3.1具体改进的项目。The Sender is set on emails to help on hosts that limit which email addresses can send (<a href="http://trac.wordpress.org/ticket/5007">#5007</a>). 然后又跟着看#5007的内容。这才找到了原因所在。因为2.3.1内增加了对邮件发送者的定义。</p>
<p>找到问题症结后，解决方法也很简单，用文本编辑器打开位于wp-includes目录下的pluggable.php，跳到line228，</p>
<blockquote><p><span style="color: blue">$phpmailer</span><span style="color: purple">-&gt; </span>Sender <span style="color: purple">=</span> apply_filters( <span style="color: red">&#8216;wp_mail_from&#8217;</span>, <span style="color: blue">$from_email</span> );</p>
</blockquote>
<p>&nbsp;</p>
<p>正是该行造成了内置邮件发送功能失效。直接删除此行，或者在行首加上注释代码:&#8221;//&#8221;。如</p>
<blockquote><p><span style="color: #008000">//$phpmailer-&gt;Sender = apply_filters( &#8216;wp_mail_from&#8217;, $from_email );</span></p>
</blockquote>
<p>&nbsp;</p>
<p>将修改后的pluggable.php重新上传都网站。然后您就发现一切OK了。</p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/830.html#comments">评论20:</a></p><p><strong>20.</strong><i>2009.01.10.12:16.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-85222" rel="nofollow">@shamas </a>文中的这个问题，在2.3.3以后已经被修复了。你的问题，要好好检查下模板，编制是否规范符合wp要求等。</p><p><strong>19.</strong><i>2009.01.10.9:36.am</i>.&nbsp;<a href="http://3284265.cn">shamas</a>: 我的博客也有个奇怪的问题，只能收到页面的评论邮件提醒，而日志里面的评论就没有邮件提醒</p><p><strong>18.</strong><i>2008.10.22.11:49.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-74786" rel="nofollow">@HE Yi </a>文首已经提了，此问题在2.3.3中已被解决了。如果你是因为更改email无法收到邮件通知的话，先确认下邮件功能是否还能正常使用。mailtocommenter插件里面提供了邮件测试的功能。如果邮件没问题，再查看下是否你的email服务器是否拒绝接受网站的邮件，或判断为spam。</p><p><strong>17.</strong><i>2008.10.22.9:31.pm</i>.&nbsp;<a href="http://heyi.name">HE Yi</a>: 我今天新修改了后台管理员的Email，再也收不到新评论提醒了，这种方法可行？ <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_eek.gif' alt=':shock:' class='wp-smiley' /> </p><p><strong>16.</strong><i>2008.05.22.9:25.am</i>.&nbsp;<a href="http://www.guwei.org">Guwei</a>: 从WP论坛看到，果然有效</p><p><strong>15.</strong><i>2008.03.01.5:29.pm</i>.&nbsp;<a href="http://www.freerainbow.cn/2008/03/01/wp-backup.html">WordPress Database Backup 邮件提醒失效的解决方法 - Feel more distant , as walking more</a>: [...]      westwood的一篇文章”Wordpress 2.3.1 in detail“，里面介绍了2.3.1具体改进的项目。The Sender is set on emails to help on hosts that limit which email addresses can send (#5007). 然后又跟着看#5007的内容。这才找到了原因所在。因为2.3.1内增加了对邮件发送者的定义。  [...]</p><p><strong>14.</strong><i>2008.01.07.5:50.pm</i>.&nbsp;<a href="http://alpha.neotheme.com">!CnSoLoer</a>: 非常感谢，我之前从2.3到2.3.1的时候就出现了这问题，在中文论坛里面发帖没人回答，一直拖到2.3.2都没有好。
昨天在朋友，幸福收藏夹 博客里面提到这个问题，有人说：“不能发那是因为默认值新版本该过了，修改一下就可以了。”
我才重新注意到这个问题，然后就在中文论坛又仔细搜索了一遍，然后到这里来了，谢谢。我已经按照您给的方法修改过了，并且现在可以收到邮件了/ <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' /> </p><p><strong>13.</strong><i>2008.01.05.7:40.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: 只有通过空间商来开启mail函数的，自己是无法解决的。</p><p><strong>12.</strong><i>2008.01.05.2:34.pm</i>.&nbsp;<a href="http://KHUI.NET/WP">KHUI</a>: 你好，我用探针测试了下，发现服务器没有开启mail这个函数，该如开启呢？
麻烦告诉我下，谢谢</p><p><strong>11.</strong><i>2007.12.31.6:46.pm</i>.&nbsp;<a href="http://www.sansky.net/article/2007-12-31-wordpress-can-not-send-mail.html">wordpress升级后无法发送邮件【存储部落】网络存储技术</a>: [...]  在网上一通查找，终于又找到当时帮我解决问题的博客。为了防止以后再出现类似的问题，也为了方便大家解决问题，我将解决方法记录在此，希望能对大家有所帮助。  解决方法很简单。 [...]</p><p><strong>10.</strong><i>2007.12.31.6:13.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: Yes，我昨天升级2.3.2的时候也手动修改了。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' /> </p><p><strong>9.</strong><i>2007.12.31.5:57.pm</i>.&nbsp;<a href="http://www.sansky.net">sansky</a>: 升级到2.3.2后又出现这个问题，再一次感谢你。</p><p><strong>8.</strong><i>2007.11.23.3:40.pm</i>.&nbsp;<a href="http://www.zhex.net">zhex</a>: 刚看了你的文章，网站问题得以解决， 太感谢了</p><p><strong>7.</strong><i>2007.11.14.4:03.pm</i>.&nbsp;<a href="http://www.quhuashuai.com">Hugh</a>: 我也发现了这个问题，谢谢你的文章！</p><p><strong>6.</strong><i>2007.11.13.9:12.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: You are welcome!P.S，你的站点很漂亮。</p><p><strong>5.</strong><i>2007.11.13.12:54.am</i>.&nbsp;<a href="http://www.alanoy.cn">Alan</a>: 谢谢你的文章，我解决了这个问题了，哈哈</p><p><strong>4.</strong><i>2007.11.02.10:24.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: 这个Google Ad对我来说类似鸡肋，现在上面大概也有几十美金了。继续放下去，不知道要到猴年马月，不放广告的话，又可惜了。</p><p><strong>3.</strong><i>2007.11.01.4:45.pm</i>.&nbsp;<a href="http://www.marketing-life.cn">Shaoqing</a>: 有没注意，好像你的GOOGEL广告都是英文的。对于模板上的GOOGLE广告，换成图片广告，是不是比文字更吸引点击? 当然故意放在其他文字旁边造成误点的除外。</p><p><strong>2.</strong><i>2007.10.31.10:17.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: 嘿嘿，那个是我在评论上加了一个js，弄点搞笑提示。</p><p><strong>1.</strong><i>2007.10.31.7:20.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: 玩wp玩入迷了呢，呵呵，为什么旁边有一个“我不懂火星语”，玩笑？</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2007.12.08.10:50.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/888.html" title="2007-12-09：注，我已经写了一个插件用于含有nextpage或more标签的feed全文输出">如何使用Wordpress内置的分页（Nextpage）功能？ (52)</a></p><p><i>2007.10.22.11:05.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/822.html" title="在wordpress中，默认点击评论者的链接时，会在同一窗口内打开该链接。这在">Wordpress Hacks: 在新窗口中打开评论者链接和no follow属性 (16)</a></p><p><i>2007.09.15.10:41.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/721.html" title="继将CSS修改符合W3C规范后，今天花了点时间，也将模板代码修改完毕，通过">继续修改模板 (4)</a></p><p><i>2007.08.21.8:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/611.html" title="又是一时心血来潮，试用过Wordpress后，想装上Movable Type 4.0玩玩看。于是就">图文介绍如何在本地服务器安装Movable Type 4.0 (15)</a></p><p><i>2007.06.11.3:55.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/189.html" title="由于博客上的图片大部分都是放在Flickr上的，所以Flickr被禁后导致国内朋友">WordPress解决Flickr图片显示方法 (3)</a></p><p><i>2007.04.30.8:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/161.html" title="Widgets是一个可视化Wordpress主题侧边栏编辑插件，用户可以在Wordpress后台主">如何修改代码使主题支持widgets (5)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/830.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/830.html/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>X01HT非官方ROM无法登录Softbank网站(X-series)的解决方法</title>
		<link>http://www.thinkagain.cn/archives/825.html</link>
		<comments>http://www.thinkagain.cn/archives/825.html#comments</comments>
		<pubDate>Wed, 24 Oct 2007 14:40:40 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[PDA]]></category>
		<category><![CDATA[hermes]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[X01HT]]></category>
		<category><![CDATA[注册表]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/archives/825.html</guid>
		<description><![CDATA[此文仅适合与Softbank的X01HT用户使用。838Pro或CHT9000用户可略过。
昨晚，热心的网友kof，在Guestbook上留言，分享了一个非官方ROM无法登录Softbank网站(http://x-series.softbankmobile.co.jp)的解决方法。解决... ]]></description>
			<content:encoded><![CDATA[<p>此文仅适合与Softbank的X01HT用户使用。838Pro或CHT9000用户可略过。</p>
<p>昨晚，热心的网友kof，在Guestbook上留言，<a href="http://www.thinkagain.cn/guestbook#comment-7425" target="_blank">分享</a>了一个非官方ROM无法登录Softbank网站(<a href="http://x-series.softbankmobile.co.jp" target="_blank">http://x-series.softbankmobile.co.jp</a>)的解决方法。解决了非官方X01HT ROM的一个通病。不敢独享，发布于此，希望对其他用X01HT的朋友有所帮助。再次谢谢kof的分享。</p>
<p>这是我用WIFI登陆x-series网站的抓图，在Download里面可以下载Softbank官方提供的一些免费软件。如Softbank Mail等。如果不用MMSLite收发MMS的，除了装它就别无二选了。唯一感冒的就是它是个大块头，近8MB。最近又放出了一个3G/WIFI连接管理的软件，我还没有试用过，也不大清楚。至于XRoof，实在是用的别扭，不安装也罢。</p>
<p>X-series网站最为便利的功能就是料金照会了，点击该按钮，输入4位密码后，直接可以查询料金情况，当然，看到的内容，和用IE在<a href="https://mb.softbank.jp/scripts/japanese/mysoftbank/index.jsp" target="_blank">网页</a>上看的是一样。这不是废话!</p>
<p><img alt="无法登录x-series网站的解决方法" src="http://www.thinkagain.cn/wp-content/uploads/2007/10/2007102403.jpg" /></p>
<p>&nbsp;</p>
<p>步入，正题，介绍下解决方法，实际也很简单，只需简单增加一个键值就可以了。</p>
<p>用注册表编辑软件打开注册表，进入</p>
<blockquote><p>[HKEY_LOCAL_MACHINE\Security\Internet Explorer\User Agent]</p>
</blockquote>
<p>&nbsp;</p>
<p>在该键值下，新建一个名为&#8221;Custom&#8221;的字符串，其值为：</p>
<blockquote><p>Mozilla/4.0(compatible; MSIE 4.01; Windows CE; HTC/X01HT; PPC; 240×320)</p>
</blockquote>
<p>&nbsp;</p>
<p>如下图。</p>
<p><img alt="无法登录x-series网站的解决方法" src="http://www.thinkagain.cn/wp-content/uploads/2007/10/2007102402.jpg"/></p>
<p>&nbsp;</p>
<p>建立字符串后的User Agent如下图。</p>
<p><img height="320" alt="无法登录x-series网站的解决方法" src="http://www.thinkagain.cn/wp-content/uploads/2007/10/2007102401.jpg" width="240"/></p>
<p>&nbsp;</p>
<p>退出注册表编辑软件，重新启动X01HT，挂上3G或WIFI，进入<a href="http://x-series.softbankmobile.co.jp" target="_blank">Softbank的X-series</a>看看，应该是没问题了。</p>
<p>&nbsp;</p>
<p><strong>OEM Package下载</strong></p>
<p>我更新了Softbank info OEM Package中的rgu文件，将原User Agent下面的Custombase的字符串删掉，新增此Custom字符串。</p>
<p>需要的朋友可在此下载。</p>
<p><span class="downloadbox">
			<span class="downloadboxleft"><a title="Download softbank_info.zip" href="http://www.thinkagain.cn/?load=softbank_info.zip"><img src ="http://www.thinkagain.cn/wp-content/plugins/wsdl_manager/Default.png" alt="Download" /></a></span>
			<span class="downloadboxright"><a title="Download softbank_info.zip" href="http://www.thinkagain.cn/?load=softbank_info.zip">softbank_info.zip</a><br/>zip- File<br/>24. Oct 2007 (136Hits)</span>
		</span></p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/825.html#comments">评论15:</a></p><p><strong>15.</strong><i>2009.09.30.4:01.pm</i>.&nbsp;筱儿: 你好．我想问一下.我现在在日本．在这买的softbank的手机,想要往手机里下歌当铃声.格式应该是什么呀,mp3.wma 的都不支持</p><p><strong>14.</strong><i>2008.04.16.1:35.pm</i>.&nbsp;finger: 了解 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' /> </p><p><strong>13.</strong><i>2008.04.16.1:06.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To finger: MMSlite最好不能和Softbankmail和ROM自带的MMS软件同时使用，这点我在制作ROM文章中已经提过，p.s，MMSlite无法兼容最新的6.1版。我现在用的是Schap's 4.31 ROM(Sorry上次留言记成4.30了)。用Softbankmail收发sms或mms（S！mail）。只不过softbankmail用起来速度超级慢，这个没法了，因为这软件一直都是这样。我详细说下使用。
1.刷4.31ROM，如果已经是这个ROM的话，可以跳过，或者也可以在4.30ROM上尝试下。
2.用ROM自带的connection setup，在start-setting-connection下面可以找到。选中Japan，softbank，然后点击OK，根据提示，过一会儿后，重启，会自动添加softbank的3G连接设定到Internet，用这个设定也可以实现3G上网。
3.接着安装Softbankmail，安装后，原来系统内的SMS将全部自动被移到softbankmail中。
以上步骤顺利完成之后，x01ht应该就可以正常使用Softbank的SMS或MMS了，也可以正常用3G上网。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' />  </p><p><strong>12.</strong><i>2008.04.15.6:05.pm</i>.&nbsp;finger: 今天无意中点了你博客about me...非常惊讶 
很巧 我也是天津科大的 2006年毕业 现在日本名大情报研读m1 大师兄！
前几天老是搞不定这个短信的东西 心理有点着急 看了pdafan没两天 一知半解就刷了 一直来打扰你 真是非常抱歉！的确很多都是没仔细看...
关于你的留言不知道我现在做的对不对，我安装了你所说的版本schape的4.30ROM，修改注册表后能够登陆xseries官网。同时安装了mmslite和softbankmail，softbankmail现在是送信显示"接続できません" 受信完全不能。mmslite 好一点 能够发信，点击menu的send/receive，连接server可以接收到softbank发出的一些官方提示短信，但是其他邮箱包括手机发出的短信接收不能，自动接收不能。今天看了xda上一个增加新connection的连接，自己做了一下仍是这个毛病。已经使用内置connection设置。请师兄指教！</p><p><strong>11.</strong><i>2008.04.15.10:45.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: To Finger：哎，你都没有认真看我的留言。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_eek.gif' alt=':shock:' class='wp-smiley' /> </p><p><strong>10.</strong><i>2008.04.14.11:04.am</i>.&nbsp;finger: 我今天刷了你说的这个rom但是还是那个问题 不能发mail 不能登录 是不是我有哪个设置没有完成 需要按照xda上那个softbank 的ap设置做一下么?</p><p><strong>9.</strong><i>2008.04.13.3:33.pm</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: 说下，我现在的使用情况作为参考。用的是schape的4.30ROM，是5.2.1948，18548.0.7.0内核。使用softbankmail收发S!mail（MMS），用其内置的connection设置，可以3G上网，登录x-serires网站。
另外，你的第二个问题，由于sb没有出x01ht的官方wm6.0版，基于Dopod官方版，是可以做到mmslite收发邮件，登录x-series网站的。如果你有兴趣可以参考制作ROM的系列文章。根据其顺序，最终就可以达到此目的的。</p><p><strong>8.</strong><i>2008.04.12.4:40.pm</i>.&nbsp;finger: 错了,本来就是官方rom能上官网的....  <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_eek.gif' alt=':shock:' class='wp-smiley' />   <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_eek.gif' alt=':shock:' class='wp-smiley' />   <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_eek.gif' alt=':shock:' class='wp-smiley' /> </p><p><strong>7.</strong><i>2008.04.12.4:25.pm</i>.&nbsp;finger: 刷了x01ht的官方版,能登陆,但是安装了softbank mail以后,每次无线登陆后,似乎被屏蔽.不允许打开网页.不知道按照你的那个教程系列自己制作日文版rom可以么?以官方版为基础的话.想知道你为何不做个以x01官方版为基础的加mmslite的rom,那样不是解决了登陆问题了么?新手,疑问较多,sorry....</p><p><strong>6.</strong><i>2008.04.08.12:15.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: 再试下，加上下述定义：
字符键：CustomBase
值：HTC_Hermes Mozilla/4.0</p><p><strong>5.</strong><i>2008.04.07.3:23.pm</i>.&nbsp;finger: 还是有问题 我装了中文wm6 5.2的内核 改了此键值 仍不能登入诶 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_cry.gif' alt=':cry:' class='wp-smiley' />   <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_cry.gif' alt=':cry:' class='wp-smiley' /> </p><p><strong>4.</strong><i>2007.11.07.9:03.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: 使用msn？你用什么版本的msn？现在都是windows live了。你去下个windows live的cab包安装吧。我在x01ht上用windows live是没有什么问题的。</p><p><strong>3.</strong><i>2007.11.07.8:27.am</i>.&nbsp;hamit: 你好！
我用的是X01HT，刷了wn6.0。 但是MSN无法登陆。上网没有问题，这是什么原因。
谢谢！</p><p><strong>2.</strong><i>2007.10.26.10:14.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: x01ht用wifi上网没什么特殊设置的，只需将wifi打开，然后x01ht会自动寻找可用的wifi接入点。接着按提示连接就可以了。我一般都用wifi上网。买了个corega的无线路由，在家里设置了个无线网络。
不过你要确认下，你的usb wifi发射器？有没有提供路由功能？</p><p><strong>1.</strong><i>2007.10.26.10:09.am</i>.&nbsp;海客: 谢谢这么有价值的介绍。想问问陈兄的是，用WIFI上网的时候，设置方面有什么特殊要求吗？我现在买了个USB WIFI发射器(？)，通过它我的NDSL能够上网了，但是X01HT折腾了老半天也还是不行，不知道问题出在哪里。</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2007.07.29.12:55.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/265.html" title="刷了HTC官方版838Pro后发现，运营商服务网络名称显示不是Softbank，而是原先">注册表修改个性化X01HT(Hermes)运营商服务网络名称显示 (0)</a></p><p><i>2007.10.16.5:49.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/816.html" title="还是应网友MoonySay的留言，在此介绍下WM6.0注册表中，屏幕位置相关的注册">WM6.0注册表中屏幕位置的相关信息 (8)</a></p><p><i>2007.10.16.12:04.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/815.html" title="今天，网友MoonySay在站上留言，提到因为他的X01HT触摸屏坏掉，所以在开机">注册表修改自定义Welcome.exe执行内容 (13)</a></p><p><i>2007.06.04.8:43.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/179.html" title="升级到wm6.0后，不免开始对系统进行调整了。在wm6.0下可以通过修改注册表">WM6.0修改注册表自定义Today显示文字 (1)</a></p><p><i>2007.01.07.12:31.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/57.html" title="通过注册表修改可以在PDA今日任务栏中增加日期显示功能。该方法在本人的">注册表修改让任务栏增加日期显示(WM5.0) (0)</a></p><p><i>2007.01.05.1:37.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/63.html" title="通过注册表修改来关掉具有照相功能的PDA照相时的快门声音。该方法在本人">注册表修改关掉照相快门声音(PocketPC WM5.0) (0)</a></p><p><i>2007.10.12.12:47.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/809.html" title="刚才查看网站的流量统计，发现这个月内有很多流量是来自PDAFans论坛。其">PDAFans上的留言 (17)</a></p><p><i>2007.10.09.8:04.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/808.html" title="前一段时间，有网友留言问如何刷ROM。其实，在我撰写的DIY基于Dopod官方WM6.">图文介绍用Custom RUU刷Hermes系列的ROM (8)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/825.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/825.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
<enclosure url="" length="" type="" />
		</item>
		<item>
		<title>WordPress Hacks: 在新窗口中打开评论者链接和no follow属性</title>
		<link>http://www.thinkagain.cn/archives/822.html</link>
		<comments>http://www.thinkagain.cn/archives/822.html#comments</comments>
		<pubDate>Mon, 22 Oct 2007 15:05:26 +0000</pubDate>
		<dc:creator>山之岚</dc:creator>
				<category><![CDATA[Blogger]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.thinkagain.cn/archives/822.html</guid>
		<description><![CDATA[在wordpress中，默认点击评论者的链接时，会在同一窗口内打开该链接。这在浏览时，颇有不便。通过一个很简单的代码修改就可以将它改为在新窗口中打开评论者链接。您所需的仅是文本编辑... ]]></description>
			<content:encoded><![CDATA[<p>在wordpress中，默认点击评论者的链接时，会在同一窗口内打开该链接。这在浏览时，颇有不便。通过一个很简单的代码修改就可以将它改为在新窗口中打开评论者链接。您所需的仅是文本编辑工具Notepad，或者更高级点，更易于代码编辑的免费开源编辑软件<a href="http://www.thinkagain.cn/download" target="_blank">Notepad++</a>。</p>
<p>在新窗口中打开链接，仅需在超链接元素&lt;a&gt;的html代码定义中加入：</p>
<blockquote><p>target=&#8221;<span style="color: #8b0000">_blank</span>&#8220;</p>
</blockquote>
<p>&nbsp;</p>
<p>即可以实现。所以我们可以直接查找评论者链接的定义函数，将上述代码加入链接的定义中。</p>
<p>以官方版Wordpress2.3为例，进入\wp-includes目录，用文本编辑器，推荐用Notepad++，打开comment-template.php，查找如下代码，在第48行：</p>
<blockquote><p>$<span style="color: #0000ff">return</span> = &#8220;<span style="color: #8b0000">&lt;a href=&#8217;$url&#8217; rel=&#8217;external nofollow&#8217;&gt;$author&lt;/a&gt;</span>&#8220;;</p></blockquote>
<p>&nbsp;</p>
<p>该语句是get_comment_author_link()函数的返回值，从字面就可以得知，这个函数的作用在于获取评论者的链接。很明显，语句中$return变量返回的就是评论者的链接地址，我们可以直接在href前面加上target=&#8221;_blank&#8221;，如：</p>
<blockquote><p>$<span style="color: #0000ff">return</span> = &#8220;<span style="color: #8b0000">&lt;a target=&#8217;_blank&#8217; href=&#8217;$url&#8217; rel=&#8217;external nofollow&#8217;&gt;$author&lt;/a&gt;</span>&#8220;;</p>
</blockquote>
<p>&nbsp;</p>
<p>注意上述语句中的，</p>
<blockquote><p><span style="color: #8b0000">rel=&#8217;external nofollow&#8217;</span></p>
</blockquote>
<p><span style="color: #8b0000"></span>&nbsp;</p>
<p><a href="http://en.wikipedia.org/wiki/Nofollow" target="_blank">nofollow属性</a>，是Google在2005为了降低SPAM索引而提倡采用的一个非正式html属性。它的用途在于告诉搜索引擎，该链接是外部链接，此链接不会对所指向的网页或站点的索引有影响，也就是说搜索引擎在抓取到该链接时，不会去索引该链接指向页面的PR。据说，Yahoo和MSN目前也支持该属性。</p>
<p><u>如果您认为您的博客不需要nofollow，直接将上述语句中的rel=&#8217;external nofollow&#8217;删掉即可。</u>删除或保留，<em><strong>UP TO YOU!</strong></em></p>
<p>注，此改法适用于调用comment_author_link()函数来返回评论者链接的模板。默认模板，或如无特殊情况，一般模板都使用该函数返回评论者链接。</p>
<hr/><p style="font-size:1.5em;font-weight:bold;"><a href="http://www.thinkagain.cn/archives/822.html#comments">评论16:</a></p><p><strong>16.</strong><i>2010.05.12.3:32.pm</i>.&nbsp;<a href="http://blog.xianyunyehe.net/689">wordpress评论者网站在新页面打开 | 闲云野鹤情侣博客</a>: [...] 又折腾了一次博客，这次不是折腾主题，是折腾wordpress自带的源码。原因是今天小卢想要评论者的网站在新窗口打开，我也想要这个功能，于是我俩就找。最后，终于找到了，原文在这里，不过上面修改的是wordpress 2.3，已经有些不适用新的版本了，所以，我决定写一篇新的来告诉大家！ [...]</p><p><strong>15.</strong><i>2009.10.11.2:32.am</i>.&nbsp;<a href="http://www.wuyablog.cn">无涯博客</a>: 不知道现在新版本的2.8下，这么实现这效果？</p><p><strong>14.</strong><i>2009.10.05.11:32.am</i>.&nbsp;<a href="http://www.os8.org/2009/10/comments-in-a-new-window-attributes-those-links-and-no-follow.html">系统吧 &raquo; 在新窗口中打开评论者链接和no follow属性</a>: [...] 在wordpress中，默认点击评论者的链接时，会在同一窗口内打开该链接。这在浏览时，颇有不便。通过一个很简单的代码修改就可以将它改为在新窗口中打开评论者链接。您所需的仅是文本编辑工具Notepad，或者更高级点，更易于代码编辑的免费开源编辑软件Notepad++。&nbsp; [...]</p><p><strong>13.</strong><i>2009.06.10.9:07.pm</i>.&nbsp;<a href="http://www.99xunle.com">cyang</a>: thank you ！ 我按你的办法实现了 target=_blank.

现在wordpress 2.7 的 $return = “<a href="’$url’" rel="nofollow">$author</a>“; 在148行了。</p><p><strong>12.</strong><i>2009.05.05.10:12.pm</i>.&nbsp;<a href="http://duqq.org">丘丘</a>: 有没有只简单修改theme，而不修改程序本身的办法呢。</p><p><strong>11.</strong><i>2009.04.10.10:53.pm</i>.&nbsp;<a href="http://www.alive77.cn">z.Yleo77</a>: 看过。。   这么回事。。。</p><p><strong>10.</strong><i>2008.12.06.6:12.pm</i>.&nbsp;<a href="http://so.sorry">plasaear</a>:  <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_arrow.gif' alt=':arrow:' class='wp-smiley' />  不错的地方...Thinkagain..</p><p><strong>9.</strong><i>2008.09.02.9:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: <a href="#comment-70543" rel="nofollow">@googlefish </a>呵呵，近段没有打算写新插件，因为没有idea或新应用之类的，倒是准备打算将几个旧插件逐步升级下。 <img src='http://www.thinkagain.cn/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' /> </p><p><strong>8.</strong><i>2008.09.01.9:07.pm</i>.&nbsp;<a href="http://www.girlqiqi.cn">googlefish</a>: think是不是又要出新的插件了.刚才好象看到了测试页面.很期待......</p><p><strong>7.</strong><i>2008.09.01.9:03.pm</i>.&nbsp;<a href="http://www.girlqiqi.cn">googlefish</a>: pr低的小站,如我,还是去掉nofollow吧,这样对评论者显得更友好,亲切些.</p><p><strong>6.</strong><i>2007.12.31.10:28.pm</i>.&nbsp;<a href="http://www.china-stone-export.com">Granite Counter Tops</a>: 非常同意你的观点</p><p><strong>5.</strong><i>2007.11.09.7:02.am</i>.&nbsp;<a href="http://www.digbuzz.com/">Digbuzz</a>: 好文，放到我挖网( <a href="http://www.digbuzz.com" rel="nofollow">digbuzz.com</a> )挖一挖会不错，还可给你带来大量流量！</p><p><strong>4.</strong><i>2007.10.28.7:44.pm</i>.&nbsp;<a href="http://ecvip.org/search-engine/seo/take-off-rel-external-nofollow.html">回馈读者，拿掉NoFollow链接安全套 | 电子商务博客-关注电子商务、网络营销以及SEO</a>: [...] 如果你也想拿掉NoFollow，这里有操作方法。     本文Tags：Blogger, Google, Spam, dofollow, nofollow 作者：黄海均 原载：电子商务博客 欢迎转载，原创文章转载时必须以链接形式注明作者和原始出处及本声明。  喜欢本文？您可以订阅我了解更多网络营销、电子商务、搜索引擎信息。如何订阅RSS？  阿里妈妈再掀疯狂采购风，网站广告位严重告急，急召天下站长！ [...]</p><p><strong>3.</strong><i>2007.10.23.5:41.pm</i>.&nbsp;<a href="http://lxz.name">ddkk3000</a>: 看来有必要对我的这个简单模板做一次大改了</p><p><strong>2.</strong><i>2007.10.23.12:01.am</i>.&nbsp;<a href="http://www.thinkagain.cn">山之岚</a>: 个人习惯是在新窗口中打开链接，因为这样还可以保持浏览原窗口的内容。我这里只是介绍下做法。至于改不改，自行决定。</p><p><strong>1.</strong><i>2007.10.22.11:21.pm</i>.&nbsp;<a href="http://ecvip.org/">oxygen</a>: 在新窗口中打开，在某些地方是中国网民的习惯。国外的网站都是在原窗口中打开，不利于浏览。

有时候还可以增加PV，哈哈哈哈……</p><hr/><p style="font-size:1.5em;font-weight:bold;">推荐阅读</p><p><i>2008.09.09.8:58.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/994.html" title="今天，Wordpress官方发布了2.6.2版。没有跑去Trac看代码变动地方，直接就将程">Wordpress Hacks:WP2.2版后中文邮件标题乱码解决方法 (22)</a></p><p><i>2008.07.27.10:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/971.html" title="WP2.6带来了很多新功能。如后台的turbo等。相比2.3到2.5，2.5到2.6之间给我的">Wordpress Hacks:如何关闭WP2.6的主题预览 (18)</a></p><p><i>2007.12.08.10:50.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/888.html" title="2007-12-09：注，我已经写了一个插件用于含有nextpage或more标签的feed全文输出">如何使用Wordpress内置的分页（Nextpage）功能？ (52)</a></p><p><i>2007.10.31.12:42.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/830.html" title="Updated:此问题已经在2.3.3中被修复。
*****************************
前几天，将Wordp">Wordpress Hacks:升级2.3.1可能出现邮件提醒失效的解决方法 (20)</a></p><p><i>2007.09.15.10:41.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/721.html" title="继将CSS修改符合W3C规范后，今天花了点时间，也将模板代码修改完毕，通过">继续修改模板 (4)</a></p><p><i>2007.08.21.8:44.am</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/611.html" title="又是一时心血来潮，试用过Wordpress后，想装上Movable Type 4.0玩玩看。于是就">图文介绍如何在本地服务器安装Movable Type 4.0 (15)</a></p><p><i>2007.06.11.3:55.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/189.html" title="由于博客上的图片大部分都是放在Flickr上的，所以Flickr被禁后导致国内朋友">WordPress解决Flickr图片显示方法 (3)</a></p><p><i>2007.04.30.8:14.pm</i>.&nbsp;<a href="http://www.thinkagain.cn/archives/161.html" title="Widgets是一个可视化Wordpress主题侧边栏编辑插件，用户可以在Wordpress后台主">如何修改代码使主题支持widgets (5)</a></p><hr/><p>Copyright &copy; 2012&nbsp;|&nbsp;<a href="http://www.thinkagain.cn">Think Again</a>&nbsp;|&nbsp;<a href="http://www.thinkagain.cn/archives/822.html">原文链接</a></p><img src="http://img.tongji.cn.yahoo.com/710673/ystat.gif"/>]]></content:encoded>
			<wfw:commentRss>http://www.thinkagain.cn/archives/822.html/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

