<?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>phpabc.cn &#187; WordPress</title>
	<atom:link href="http://www.phpabc.cn/category/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phpabc.cn</link>
	<description></description>
	<lastBuildDate>Thu, 20 Oct 2011 07:55:06 +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>WordPress SQL调用Discuz的方法</title>
		<link>http://www.phpabc.cn/wordpress-sqldiao-yong-discuzde-fang-fa.html</link>
		<comments>http://www.phpabc.cn/wordpress-sqldiao-yong-discuzde-fang-fa.html#comments</comments>
		<pubDate>Mon, 26 Sep 2011 02:48:55 +0000</pubDate>
		<dc:creator>hew</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Discuz]]></category>
		<category><![CDATA[SQL调用]]></category>

		<guid isPermaLink="false">http://www.phpabc.cn/?p=940</guid>
		<description><![CDATA[调用代码： &#60;ul&#62; &#60;?php //截取utf8字符串 function utf8Substring&#40;$str, $from, $len&#41;&#123; return preg_replace&#40;'#^(?:[\x00-\x7F]&#124;[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'. '((?:[\x00-\x7F]&#124;[\xC0-\xFF][\x80-\xBF]+){0,'... ]]></description>
			<content:encoded><![CDATA[<p>调用代码：<br />
<span id="more-940"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;ul&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> 
        <span style="color: #666666; font-style: italic;">//截取utf8字符串</span>
        <span style="color: #000000; font-weight: bold;">function</span> utf8Substring<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$from</span><span style="color: #339933;">,</span> <span style="color: #000088;">$len</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'</span><span style="color: #339933;">.</span><span style="color: #000088;">$from</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'}'</span><span style="color: #339933;">.</span>
                <span style="color: #0000ff;">'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'</span><span style="color: #339933;">.</span><span style="color: #000088;">$len</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'}).*#s'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'$1'</span><span style="color: #339933;">,</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #666666; font-style: italic;">//建立数据库链接</span>
        <span style="color: #000088;">$conn</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;数据库用户名&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;数据库密码&quot;</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;数据库链接错误&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//指定要链接的数据库</span>
        <span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;数据库&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//使用UTF-8中文编码;</span>
        <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;set names 'UTF-8'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        <span style="color: #666666; font-style: italic;">//指定版块的所有文章中取10条最新帖子</span>
<span style="color: #000088;">$SQL</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;SELECT tid,subject FROM 表名 where fid in (版块1,版块2……) ORDER BY tid DESC LIMIT 0,10&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$query</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//循环显示结果</span>
        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;li&gt;&lt;span class=titlel&gt;&lt;a class=title title=&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span>subject<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; href=http://www.dzbbs.xxx/thread-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span>tid<span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-1-1.html target=_blank&gt;&quot;</span><span style="color: #339933;">.</span>
                    utf8Substring<span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span>subject<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">40</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//关闭链接</span>
<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ul&gt;</pre></div></div>

<p>如果调用的时候出现了错误试着把上面代码的如下部分删除</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//关闭链接</span>
<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.phpabc.cn/wordpress-sqldiao-yong-discuzde-fang-fa.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>非插件实现WordPress 随机文章相关文章</title>
		<link>http://www.phpabc.cn/fei-cha-jian-shi-xian-wordpress-sui-ji-wen-zhang-xiang-guan-wen-zhang.html</link>
		<comments>http://www.phpabc.cn/fei-cha-jian-shi-xian-wordpress-sui-ji-wen-zhang-xiang-guan-wen-zhang.html#comments</comments>
		<pubDate>Mon, 20 Dec 2010 07:44:25 +0000</pubDate>
		<dc:creator>hew</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[相关文章]]></category>
		<category><![CDATA[随机文章]]></category>

		<guid isPermaLink="false">http://www.phpabc.cn/?p=924</guid>
		<description><![CDATA[使用wordpress 自带函数实现随机文章和相关文章 获取相关文章的代码如下： &#60;li id=&#34;relative&#34; class=&#34;widget-container&#34;&#62; &#60;h3 class=&#34;widget-title&#34;&#62;Relative Posts&#60;/h3&#62; &#60;ul&#62; &#60;... ]]></description>
			<content:encoded><![CDATA[<p>使用wordpress 自带函数实现随机文章和相关文章<br />
获取相关文章的代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;li id=&quot;relative&quot; class=&quot;widget-container&quot;&gt;
    &lt;h3 class=&quot;widget-title&quot;&gt;Relative Posts&lt;/h3&gt;
    &lt;ul&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$tags</span> <span style="color: #339933;">=</span> wp_get_post_tags<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$tagg</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$tags_id</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tagg</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">term_id</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$args</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'tag__in'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$tags_id</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'post__not_in'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'showposts'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'caller_get_posts'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$my_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
            &lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title_attribute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/ul&gt;
&lt;/li&gt;</pre></div></div>

<p><span id="more-924"></span><br />
随机文章的代码如下：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;li id=&quot;random&quot; class=&quot;widget-container&quot;&gt;
    &lt;h3 class=&quot;widget-title&quot;&gt;Random Posts&lt;/h3&gt;
    &lt;ul&gt;
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$randomPosts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT ID, post_title FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span> WHERE ID != <span style="color: #006699; font-weight: bold;">$post-&gt;ID</span> AND post_status = 'publish' AND post_type = 'post' ORDER BY rand() LIMIT 10&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$randomPosts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$randomPost</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
            &lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$randomPost</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$randomPost</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$randomPost</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;
        <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/ul&gt;
&lt;/li&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.phpabc.cn/fei-cha-jian-shi-xian-wordpress-sui-ji-wen-zhang-xiang-guan-wen-zhang.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 首页文章后插入广告</title>
		<link>http://www.phpabc.cn/wordpress-shou-ye-wen-zhang-hou-cha-ru-guang-gao.html</link>
		<comments>http://www.phpabc.cn/wordpress-shou-ye-wen-zhang-hou-cha-ru-guang-gao.html#comments</comments>
		<pubDate>Tue, 14 Dec 2010 11:32:53 +0000</pubDate>
		<dc:creator>hew</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[广告]]></category>

		<guid isPermaLink="false">http://www.phpabc.cn/?p=910</guid>
		<description><![CDATA[在不用插件的情况下给 WordPress 的首页插广告，其中广告只在第一篇文章后显示，偶尔也需要第二篇后显示。最简单的方法应该是把显示楼层数的思路拿过来。 首先，编辑 index.php，如果你的arch... ]]></description>
			<content:encoded><![CDATA[<p>在不用插件的情况下给 WordPress 的首页插广告，其中广告只在第一篇文章后显示，偶尔也需要第二篇后显示。最简单的方法应该是把显示楼层数的思路拿过来。</p>
<p>首先，编辑 index.php，如果你的archive.php 或者 category.php 与index.php类似，那么你都可以照如下方法编辑：<br />
<span id="more-910"></span><br />
在</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   1. <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>之前插入</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   1. <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$postcnt</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>然后，找到</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   1. <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>，在它后面写：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   1. <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcnt</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
   2. 广告代码
   3. <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000088;">$postcnt</span><span style="color: #339933;">++;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>然后目的实现。这个应该不止可以用来插广告。</p>
<p>如果要在第二篇甚至第三篇也显示广告只用写：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   1. <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcnt</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span> or <span style="color: #000088;">$postcnt</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>广告管理就很方便了，关键是无需插件。</p>
<p>另外一种更为简单的方法：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">   1. <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_post</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
   2. 广告代码位置
   3. <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.phpabc.cn/wordpress-shou-ye-wen-zhang-hou-cha-ru-guang-gao.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>为 WordPress 的 Read more 加上 nofollow</title>
		<link>http://www.phpabc.cn/wei-wordpress-de-read-more-jia-shang-nofollow.html</link>
		<comments>http://www.phpabc.cn/wei-wordpress-de-read-more-jia-shang-nofollow.html#comments</comments>
		<pubDate>Mon, 19 Jul 2010 12:31:03 +0000</pubDate>
		<dc:creator>hew</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[nofollow]]></category>
		<category><![CDATA[read more]]></category>

		<guid isPermaLink="false">http://www.phpabc.cn/?p=693</guid>
		<description><![CDATA[前段时间写过一篇关于 WordPress SEO 技巧的带建议性质的文章, 貌似大家很喜欢. 但那看似一个列表, 部分内容并没有给出具体的解决办法, 所以有很多同学提问了. 其中一个问题被问得最多: 怎样... ]]></description>
			<content:encoded><![CDATA[<p>前段时间写过一篇关于 WordPress SEO 技巧的带建议性质的文章, 貌似大家很喜欢. 但那看似一个列表, 部分内容并没有给出具体的解决办法, 所以有很多同学提问了. 其中一个问题被问得最多:</p>
<p>怎样为 Read more 加上 rel=”nofollow” 属性?<br />
<span id="more-693"></span><br />
我不写出实现方法是有原因的.<br />
1. 实现方法简单<br />
2. 实现方法很多<br />
3. 我的实现方法比较粗暴</p>
<p>不管如何, 既然这么多人感兴趣, 我就提出来说说吧.</p>
<p>以下我列举三种实现方法.<br />
1. 打开 {WordPress 根目录}/wp-includes/post-template.php 文件, 然后在 get_the_content 方法里为 Read more 链接加上 rel=”nofollow”.<br />
2. 在主题目录的 function.php 文件里重写 the_content 或者 get_the_content 方法.<br />
3. 用 PHP 截取 the_content 输出的文本, 加上 nofollow 属性后再输出文本.</p>
<p>其中方法 2 和方法 3 可做成插件实现.<br />
方法 1 简单方便, 而且效率最高, 所以我直接改了 WordPress 的源代码. 至于你选择哪种, 那只能由你自己判断了.</p>
<p>建议不明白真相的观众阅读我的上一篇文章, 在本站搜索栏搜索 “WordPress SEO” 既可找到. </p>
<p>实现代码</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content_more_link'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'nofollowReadMore'</span> <span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> nofollowReadMore<span style="color: #009900;">&#40;</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class=&quot;more-link&quot;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'class=&quot;more-link&quot; rel=&quot;nofollow&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$link</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.phpabc.cn/wei-wordpress-de-read-more-jia-shang-nofollow.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>给广告一个关闭的按钮</title>
		<link>http://www.phpabc.cn/gei-guang-gao-yi-ge-guan-bi-de-an-niu.html</link>
		<comments>http://www.phpabc.cn/gei-guang-gao-yi-ge-guan-bi-de-an-niu.html#comments</comments>
		<pubDate>Mon, 19 Jul 2010 12:28:17 +0000</pubDate>
		<dc:creator>hew</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[广告]]></category>
		<category><![CDATA[按钮]]></category>

		<guid isPermaLink="false">http://www.phpabc.cn/?p=691</guid>
		<description><![CDATA[很多的站点不管流量,点击是多是少,站长们总是喜欢放些放广告,虽然大多数都挣不到钱,但挣一分是一分.所以从这个方面讲,放置一定量的广告无可厚非.另一角度从用户体验来讲总是多少的要受... ]]></description>
			<content:encoded><![CDATA[<p>很多的站点不管流量,点击是多是少,站长们总是喜欢放些放广告,虽然大多数都挣不到钱,但挣一分是一分.所以从这个方面讲,放置一定量的广告无可厚非.另一角度从用户体验来讲总是多少的要受到影响.比如造成页面的混乱,加载速度的延长等.</p>
<p>我是个比较喜欢整洁的人.对页面比较乱的网页有一种烦躁感.比如很花哨的QQ空间等.因此我几乎不去,虽然现在QQ空间对Firefox的支持已经做得很好了.但是页面的混乱还是让我无法忍受.同样对于广告满天飞的下载站,连找个链接都困难的情况来说,我更是郁闷.所以以下文字可能对喜欢整洁和关注用户体验的朋友有用.<br />
<span id="more-691"></span><br />
以下实例针对WordPress.</p>
<p>实现的原理是写入Cookie非常简单.这个由javascript脚本来完成.然后由php判断Cookie.(我认为这种方式比较好)</p>
<p>首先,我们来创建个写Cookie的js.代码如下:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">function</span> SetCookie<span style="color: #009900;">&#40;</span>c_name<span style="color: #339933;">,</span>value<span style="color: #339933;">,</span>expiredays<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> exdate<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	exdate.<span style="color: #660066;">setDate</span><span style="color: #009900;">&#40;</span>exdate.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>expiredays<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	document.<span style="color: #660066;">cookie</span><span style="color: #339933;">=</span>c_name<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #339933;">+</span>escape<span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>
		<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>expiredays<span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;;expires=&quot;</span><span style="color: #339933;">+</span>exdate.<span style="color: #660066;">toGMTString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
window<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'PHC'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
window<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'PHC'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'SetCookie'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> SetCookie<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>这里我用到了mg12介绍的JavaScript的命名空间.具体的介绍请<a href="http://www.neoease.com/tag/javascript/">移步</a>查看.</p>
<p>然后我们在广告代码的相应位置插入一个关闭的按钮,这些简单的html代码我就不细说了.</p>
<p>由于我的主题载入了jQuery框架.因此一下代码是基于jQuery的.当然你也可以用其他的办法.只是需要多敲点代码.<br />
好了以下是我的代码.请参照相应的DOM结构查看.(每个人的情况都不同.不可通用.只能这样了)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.singleggad .close'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.singleggad'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	PHC.<span style="color: #660066;">SetCookie</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'philna_singlepage_ad'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'no'</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	setTimeout<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'This advertisement will no longer display in two days!'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>以上代码的效果是,点击关闭.广告被隐藏.同时写入Cookie,名称为philna_singlepage_ad,值为:no,有效期为2天,然后延时1秒钟后弹出警告告知之访客.这样一个Cookie便写入了.</p>
<p>然后我们要利用刚刚写入的Cookie来判断是否显示广告.我推荐使用php的方法.代码如下:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'philna_singlepage_ad'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">'no'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;!--这个放你的广告代码--&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>这样处理有个好处,如果判断为不显示广告,那么整个广告代码都不会显示出来.当然就不会再去下载广告代码,浪费用户等待时间.网上有部分介绍,依然是通过js判断Cookie并隐藏广告.这个方法很糟糕,至少要等DOM下载完了你的js才能工作.这就意味着浪费的用户等待时间,并且效果还不好.会出现广告出现,又很快消失的情况.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpabc.cn/gei-guang-gao-yi-ge-guan-bi-de-an-niu.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>基于 javascript 的简单缓存思路</title>
		<link>http://www.phpabc.cn/ji-yu-javascript-de-jian-dan-huan-cun-si-lu.html</link>
		<comments>http://www.phpabc.cn/ji-yu-javascript-de-jian-dan-huan-cun-si-lu.html#comments</comments>
		<pubDate>Mon, 19 Jul 2010 12:16:19 +0000</pubDate>
		<dc:creator>hew</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Cache]]></category>

		<guid isPermaLink="false">http://www.phpabc.cn/?p=689</guid>
		<description><![CDATA[我在博客上用了很多的 javascript 代码, 来实现些简单的动画效果和 Ajax . 本意是为了好看, 增强用户体验但是也不得不有所牺牲: 1. 可能会增加数据库请求. 2. 无法使用浏览器前进后退按钮. 今天... ]]></description>
			<content:encoded><![CDATA[<p>我在博客上用了很多的 javascript 代码, 来实现些简单的动画效果和 Ajax . 本意是为了好看, 增强用户体验但是也不得不有所牺牲: 1. 可能会增加数据库请求. 2. 无法使用浏览器前进后退按钮.</p>
<p>今天写个思路来缓解一下第一个问题 ( 数据库请求 ) 注意只是缓解. 因为不是真正的缓存.</p>
<p>我们知道所以的 Ajax 请求其实和不同的请求是没有什么两样的. 但它也有自己的特点:<br />
<span id="more-689"></span><br />
   1. 通过特定的 URL 请服务器请求数据.<br />
   2. 可能包含特定的头部信息 ( RequestHeader ) .<br />
   3. 服务器端有专门的代码来识别这些特殊请求, 并作相应处理.</p>
<p>Ajax 只是可能增加数据库请求, 并不是绝对会增加数据库请求. 这个要具体情况具体分析. 像我目前使用的这种分页方法就没有增加反而是减少请求.</p>
<p>我的思路是将请求返回的数据在展示的同时也放到一个数组变量里, 在下次请求的时候直接从这个缓存变量中取值. 因此, 这时 Ajax 的请求顺序变为: 先判断缓存如果有需要的数据则返回缓存数据, 没有则执行 Ajax 请求, 并在请求成功后缓存返回数据.</p>
<p>以 Ajax 分页 举例:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/* 建立一个用于缓存的数组 */</span>
<span style="color: #003366; font-weight: bold;">var</span> ajaxpageCache <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> ajaxpage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009966; font-style: italic;">/* 取得链接 */</span>
	<span style="color: #003366; font-weight: bold;">var</span> nav_a <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#navigation a'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009966; font-style: italic;">/* 注册链接单击事件 */</span>
	nav_a.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009966; font-style: italic;">/* 获取链接值 */</span>
		<span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009966; font-style: italic;">/* 判断缓存, 缓存中有值则使用缓存数据 */</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ajaxpageCache<span style="color: #009900;">&#91;</span>url<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#content'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>ajaxpageCache<span style="color: #009900;">&#91;</span>url<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009966; font-style: italic;">/* 平滑移动到头部的动画 */</span>
			$.<span style="color: #660066;">scrollTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#header'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">800</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009966; font-style: italic;">/* 重新注册该事件 */</span>
			ajaxpage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009966; font-style: italic;">/* 阻止打开链接 */</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* ... 省略的代码 ... */</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* 请求前 */</span>
		<span style="color: #003366; font-weight: bold;">var</span> beforeSend <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #009966; font-style: italic;">/* ... 省略的代码 ... */</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* 请求失败时 */</span>
		<span style="color: #003366; font-weight: bold;">var</span> error <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>request<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #009966; font-style: italic;">/* ... 省略的代码 ... */</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* 请求成功 */</span>
		<span style="color: #003366; font-weight: bold;">var</span> success <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #009966; font-style: italic;">/* 展示(显示返回数据) */</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#content'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009966; font-style: italic;">/* 写入缓存 */</span>
			ajaxpageCache<span style="color: #009900;">&#91;</span>url<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> data<span style="color: #339933;">;</span>
			<span style="color: #009966; font-style: italic;">/* ... 省略的代码 ... */</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* 启动 Ajax 请求 */</span>
		ajax<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'POST'</span><span style="color: #339933;">,</span> url<span style="color: #339933;">,</span> data<span style="color: #339933;">,</span> beforeSend<span style="color: #339933;">,</span> error<span style="color: #339933;">,</span> success<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009966; font-style: italic;">/* 阻止打开链接 */</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>这种缓存思路只是对重复使用相同数据的请求适用. 比如这种大页面翻页等.因为只要页面重新加载所有缓存内容将消失.</p>
<p>当然, 没有好处我也不会使用. 它的优点是在请求重复性数据时不产生数据库请求, 直接从客户端返回数据也让内容显示几乎没有延时. 在本地测试 Ajax 的时候可能并没有什么感觉, 一旦上传到网站, 在网速较慢的情况下就很明显的感觉慢.</p>
<p>考虑更高级一点的应用</p>
<p>   1. 使用预加载, 即预先在’后台偷偷’将下一页的内容加载到缓存. (目前我还不想使用. 因为不是每个人都一定要看下一页的)<br />
   2. 定时清空指定的缓存数据.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpabc.cn/ji-yu-javascript-de-jian-dan-huan-cun-si-lu.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>优化 header.php 加速 WordPress</title>
		<link>http://www.phpabc.cn/you-hua-header-php-jia-su-wordpress.html</link>
		<comments>http://www.phpabc.cn/you-hua-header-php-jia-su-wordpress.html#comments</comments>
		<pubDate>Fri, 16 Jul 2010 05:56:43 +0000</pubDate>
		<dc:creator>hew</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[优化]]></category>

		<guid isPermaLink="false">http://www.phpabc.cn/?p=641</guid>
		<description><![CDATA[WordPress 以众多插件和主题而闻名，插件不仅给我们的博客提供了诸多强大的功能，而且还简便了操作美化了页面。但凡事都是具有两面性的，不少插件为了实现自己的功能 都需要引用额外的 Ja... ]]></description>
			<content:encoded><![CDATA[<p><!--/postdata --><a title="标签 wordpress 下的日志" rel="tag" href="http://zeuscn.net/archives/tag/wordpress">WordPress</a> 以众多插件和主题而闻名，插件不仅给我们的博客提供了诸多强大的功能，而且还简便了操作美化了页面。但凡事都是具有两面性的，不少插件为了实现自己的功能 都需要引用额外的 <a title="标签 JavaScript 下的日志" rel="tag" href="http://zeuscn.net/archives/tag/javascript">Javascript</a> 和 <a title="标签 css 下的日志" rel="tag" href="http://zeuscn.net/archives/tag/css">CSS</a> 样式，这些内容全部都被自动加载到了页面的  head  标签内，从一定程度上影响到了页面加载的速度。而实际上大部分时候我们不需要这些额外的内容。比如我的博客首页（index.php）、归档页 （archive.php）和搜索结果页（search.php），都不会使用我已经启用的 Audio player 、Democracy  、WP-Syntax 、CoolCode 、Clean Archives Reloaded 这几个插件，而它们都会自动将一些额外的内容加入到  head 标签内，所以我只需要<strong>根据自己的需要</strong>，让这些插件只在文章页（single.php）和页面页 （page.php）内加载即可。<span id="more-641"></span></p>
<p><a title="标签 wordpress 下的日志" rel="tag" href="http://zeuscn.net/archives/tag/wordpress">WordPress</a> 插件是根据下面这个函数进行加载的：</p>
<div>
<div>
<pre>&lt;?php wp_head(); ?&gt;</pre>
</div>
</div>
<p>我们可以在主题模板内的 header.php 文件中找到它，也就是说只要出现以上这个函数，插件就能自动将相关的内容加载到 head  标签内，如果没有这个函数，插件则不会加载这些内容。那么我只需要按照下面的写法就能按照我自己的需求在文章页（single.php）和页面页 （page.php）内加载相关的插件功能了。</p>
<div>
<div>
<pre>&lt;?php if (is_single() or is_page()) { ?&gt;
&lt;?php wp_head(); ?&gt;
&lt;?php } ?&gt;</pre>
</div>
</div>
<p>通过一个简单的判断语句我们就能有效的减少<strong>博客首页</strong>的“请求数量”以提高首页的加载速度，下面是首页和文章页  head 标签加载情况的两张对比图：（点击放大）</p>
<p><a rel="lightbox" href="http://pic.yupoo.com/zeuscn/714417c99862/wkx2p9mq.jpg"><img src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/055704cAX.jpg" alt="优化  header.php 加速 WordPress 首页加载速度" /></a></p>
<p><a rel="lightbox" href="http://pic.yupoo.com/zeuscn/118127c99866/9gc4ty5p.jpg"><img src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/055720omc.jpg" alt="优化  header.php 加速 WordPress 首页加载速度" /></a></p>
<p>基本上，效果很明显！</p>
<p>功能和速度就像鱼和熊掌一样难以兼得，对于博客/网站速度的优化还是蛮需要积累经验的。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpabc.cn/you-hua-header-php-jia-su-wordpress.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何在 WordPress 首页中第一篇文章后插入广告</title>
		<link>http://www.phpabc.cn/ru-he-zai-wordpress-shou-ye-zhong-di-yi-pian-wen-zhang-hou-cha-ru-guang-gao.html</link>
		<comments>http://www.phpabc.cn/ru-he-zai-wordpress-shou-ye-zhong-di-yi-pian-wen-zhang-hou-cha-ru-guang-gao.html#comments</comments>
		<pubDate>Fri, 16 Jul 2010 05:27:50 +0000</pubDate>
		<dc:creator>hew</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[广告]]></category>
		<category><![CDATA[插入广告]]></category>

		<guid isPermaLink="false">http://www.phpabc.cn/?p=639</guid>
		<description><![CDATA[在WordPress博客首页的第一篇或者第X篇日志后显示广告，这样即不会让访客 感觉你的站点很乱，很多广告，又能在你指定的地方放上广告。当然也不一定是广告，在日志后放上图片、小贴士、通... ]]></description>
			<content:encoded><![CDATA[<p>在WordPress博客首页的第一篇或者第X篇日志后显示广告，这样即不会让访客 感觉你的站点很乱，很多广告，又能在你指定的地方放上广告。当然也不一定是广告，在日志后放上图片、小贴士、通知等也是蛮有意思的。方法是在ShawnBlog看到</p>
<p>方法有两种，个人推荐第二个，简单，而且不需要重新创建变量。<br />
<span id="more-639"></span><br />
第一种方法：</p>
<p>1、打开index.php文件，在 <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 前插入    <?php $postcnt = 1; ?></p>
<p>2、在</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>，后加入代码：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcnt</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    广告代码
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000088;">$postcnt</span><span style="color: #339933;">++;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
如果你还想把广告加在第二篇日志后，那就将第2步中的代码<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcnt</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> 改成 <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$postcnt</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$postcnt</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>，以此类推。</p>
<p>此方法的原理：在进入日志列表循环之前，创建一个计数变量postcnt并赋值为1，然后在下面循环输出日志的时候，每 输出一篇日志摘要，技术变量postcnt就自加1，这样每篇日志就等于有各自的顺序数字了。然后在if需要的第X篇日志后显示广告。</p>
<p>第二种方法：</p>
<p>打开index.php文件，在</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>，后加入代码：</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current_post</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    广告代码
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>如果你还想把广告加在第二篇日志后，那就将代码中的$wp_query->current_post == 0 改成1，第X篇日志改成X-1，以此类推。</p>
<p>此方法的原理，由WordPress自带函数得到日志列表的日志计数，直接利用函数判断在需要的第X篇日志后显示广告。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpabc.cn/ru-he-zai-wordpress-shou-ye-zhong-di-yi-pian-wen-zhang-hou-cha-ru-guang-gao.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>如何开启WordPress 3.0多站点功能</title>
		<link>http://www.phpabc.cn/ru-he-kai-qi-wordpress-3-0duo-zhan-dian-gong-neng.html</link>
		<comments>http://www.phpabc.cn/ru-he-kai-qi-wordpress-3-0duo-zhan-dian-gong-neng.html#comments</comments>
		<pubDate>Tue, 13 Jul 2010 07:13:01 +0000</pubDate>
		<dc:creator>hew</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress 3]]></category>
		<category><![CDATA[多站点]]></category>

		<guid isPermaLink="false">http://www.phpabc.cn/?p=576</guid>
		<description><![CDATA[WordPress 3.0的一个重要更新是把多站点 (Multisite)功能支持纳入wordpress的版本进程当中，现在安装一个WordPress博客就可以管理多个博客，更可与bbPress这 个优秀的社区网络插件协助你建立一个强大... ]]></description>
			<content:encoded><![CDATA[<p>WordPress 3.0的一个重要更新是把多站点  (Multisite)功能支持纳入wordpress的版本进程当中，现在安装一个WordPress博客就可以管理多个博客，更可与bbPress这 个优秀的社区网络插件协助你建立一个强大的SNS网站社区。本篇将简略介绍如何在WordPress  3.0中开启多站点功能。详情请访问WordPress Codex：<a href="http://codex.wordpress.org/Create_A_Network">Create A Network</a>。<br />
<span id="more-576"></span><br />
<strong>第 一步</strong>：编辑根目录下的wp-config.php文件，在其中添加多站点支持配置</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_ALLOW_MULTISITE'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>然 后重新登录后台，刷新后台页面，工具菜单就能看到网络 (Network) 选项。</p>
<p><strong>第二步</strong>：建议停用大 部分与mu不兼容的插件，目前已知Google XML Sitemaps不能在多博客中使用。</p>
<p><strong>第三步</strong>： 配置网络选项<br />
网络基本设置</p>
<p><a href="http://icodex.org/wp-content/uploads/2010/06/tools-network.png"><img title="tools-network" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/071329Af3.png" alt="" width="500" height="313" /></a></p>
<p>在这个页面中，系统会提示你追加wp-config.php 的配置及编辑.htaccess文件</p>
<p><a href="http://icodex.org/wp-content/uploads/2010/06/tools-network-created.png"><img title="tools-network-created" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/071348hg6.png" alt="" width="500" height="414" /></a></p>
<p>最后：完成这些修改后，重新回到后台当中建立用户及博客吧。enjoy！</p>
<h4>提示</h4>
<p>以 下三种情况将不能使用多站点功能<br />
1.WordPress地址和博客地址不同<br />
2.WordPress地址是127.0.0.1或监听端口不是80和443端口的<br />
3.本地计算机不能使用IP地址，如127.0.0.1必须以localhost替换</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpabc.cn/ru-he-kai-qi-wordpress-3-0duo-zhan-dian-gong-neng.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DirectAdmin 面板快速安装 WordPress</title>
		<link>http://www.phpabc.cn/directadmin-mian-ban-kuai-su-an-zhuang-wordpress.html</link>
		<comments>http://www.phpabc.cn/directadmin-mian-ban-kuai-su-an-zhuang-wordpress.html#comments</comments>
		<pubDate>Tue, 13 Jul 2010 06:58:21 +0000</pubDate>
		<dc:creator>hew</dc:creator>
				<category><![CDATA[DirectAdmin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[安装]]></category>

		<guid isPermaLink="false">http://www.phpabc.cn/?p=558</guid>
		<description><![CDATA[好歹好说，被 MJJ 的酋长拉回了 Wopus 的空间，哦哈哈，反正偶05年就备案的，而且博客里也没啥和谐的东东，就算认为有也是一些擦边球，所以，买了个 独立ip 以后，就开始再次用上 Wopus 的空... ]]></description>
			<content:encoded><![CDATA[<p>好歹好说，被 <strong>MJJ</strong> 的酋长拉回了 Wopus 的空间，哦哈哈，反正偶05年就备案的，而且博客里也没啥和谐的东东，就算认为有也是一些擦边球，所以，买了个 <strong>独立ip</strong> 以后，就开始再次用上 <strong>Wopus</strong> 的空间。测试了一下<a rel="nofollow" href="http://zou.lu/php.php" target="_blank">探针</a>，完善了一下 主题和插件，然后懒得用<strong>FTP</strong>一点一点慢慢上传，所以，就教一下大家用DA面板如何快速安装 <a href="http://zou.lu/tags/wordpress/" target="_blank">WordPress</a>。</p>
<p>以 下内容可以转载，以上瞎说的东西就表转了。</p>
<p><span id="more-558"></span></p>
<p>相信大家看过或者是知道在<strong> cPanel</strong> 下快速安装 <strong>WordPress</strong> ，其实 <strong>DirectAdmin </strong>（以下简称 <strong>DA</strong>） 和 <strong>Cpanel</strong> （以下简称 <strong>CP </strong>）原理差不多，一般在 <strong>CP</strong> 下是解压 <strong>zip 文件</strong>，而在  <strong>DA</strong> 下，则是解压 <strong>tar.gz 文件</strong>。</p>
<h3>1、下载并上传压缩 包</h3>
<p>下载官网的 tar.gz 包，地址：<a href="http://wordpress.org/latest.tar.gz" target="_blank">http://wordpress.org/latest.tar.gz</a></p>
<p>然 后利用 <strong>FTP软件</strong> 上传至你的目录，我用的是 <strong>FlashFXP</strong> ，上传到  /domains/showfom.com/public_html/ ，如图：</p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065828NQA.jpg"><img title="DirectAdmin 面板快速安装  WordPress" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065828NQA.jpg" border="0" alt="DirectAdmin 面板快速安装 WordPress" width="644" height="363" /></a></p>
<p>上 传完毕，进入你的 <strong>DA 控制面板</strong>，一般是 <strong>你的域名:2222</strong> ，切记，在输入地址的时候，<strong>FireFox</strong> 下可以直接输入，比如 <strong>xxx.com:2222</strong> ，但是在<strong> IE  （无论6、7、8）</strong>下，一定要在前面加上 <strong>http</strong> ，比如<strong> http://xxx.com:2222</strong> 否则会显示网页错误，这个。。。<strong>IE</strong> 做得也太不认真了。</p>
<h3>2、解压 tar.gz</h3>
<p>进入控制面板，选择<strong>文件管理器</strong>（<strong>Files</strong>）， 进入你的目录，找到 <strong>wordpress-2.8.tar.gz</strong> ，看到那个<strong> Extract</strong> 了吧？点击，如图：</p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065839wCq.jpg"><img title="DirectAdmin 面板快速安装  WordPress" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065839wCq.jpg" border="0" alt="DirectAdmin 面板快速安装 WordPress" width="644" height="369" /></a></p>
<p>然 后会显示要解压的目录和解压的文件：</p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065851YKV.jpg"><img title="DirectAdmin 面板快速安装  WordPress" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065851YKV.jpg" border="0" alt="DirectAdmin 面板快速安装 WordPress" width="618" height="484" /></a></p>
<p>点 击释放（解压缩），如图，看到 <strong>File Extracted</strong> ，就说明成功解压。</p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065902fID.jpg"><img title="DirectAdmin 面板快速安装  WordPress" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065902fID.jpg" border="0" alt="DirectAdmin 面板快速安装 WordPress" width="644" height="205" /></a></p>
<h3>3、 转移目录</h3>
<p>这个时候解压到了一个新创建的 <strong>wordpress</strong> 的目录，在 <strong>DA  控制面板</strong>里转移目录比<strong> CP</strong> 要麻烦些，如图：</p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065914m9z.jpg"><img title="DirectAdmin 面板快速安装  WordPress" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065914m9z.jpg" border="0" alt="DirectAdmin 面板快速安装 WordPress" width="644" height="207" /></a></p>
<p>进 入 <strong>wordpress 目录</strong>，点击蓝色背景白色字的那个<strong> Select</strong> ，</p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065925t41.jpg"><img title="DirectAdmin 面板快速安装  WordPress" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065925t41.jpg" border="0" alt="DirectAdmin 面板快速安装 WordPress" width="644" height="450" /></a></p>
<p>文 件后面的选择框就会自动全部选定，这时候，点击 <strong>Add to Clipboard</strong> ，如图：</p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065937Muh.jpg"><img title="DirectAdmin 面板快速安装  WordPress" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065937Muh.jpg" border="0" alt="DirectAdmin 面板快速安装 WordPress" width="644" height="135" /></a></p>
<p>接 着返回上层目录，点击 <strong>../ Up a Level</strong> 即可：</p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065948oTW.jpg"><img title="DirectAdmin 面板快速安装  WordPress" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/065948oTW.jpg" border="0" alt="DirectAdmin 面板快速安装 WordPress" width="171" height="52" /></a></p>
<p>然 后点击下方的 <strong>Move Clipboard Files here</strong> 按钮：</p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/070000iJm.jpg"><img title="DirectAdmin 面板快速安装  WordPress" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/070000iJm.jpg" border="0" alt="DirectAdmin 面板快速安装 WordPress" width="644" height="98" /></a></p>
<p>出 现如下的提示，<strong>Do you want to overwrite any existing files</strong> ?  你想要覆盖任何已存在的文件吗？废话，当然要。</p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/070011OFh.jpg"><img title="DirectAdmin 面板快速安装  WordPress" src="http://www.phpabc.cn/wp-content/uploads/images/2010/07/070011OFh.jpg" border="0" alt="DirectAdmin 面板快速安装 WordPress" width="244" height="74" /></a></p>
<h4><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/070011OFh.jpg">4、 安装 WordPress</a></h4>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/070011OFh.jpg">接着，就出现经典的创建数据库 <strong>wp-config.php</strong> 页面（即安装），这个不用偶说大家就明白了吧。</a></p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/070011OFh.jpg"><strong>PS</strong>：由于是自动解压，所以得用 <strong>FTP</strong> 或者 <strong>DA控制面板</strong> 设定一下权限，一般的用户把 <strong>WordPress的根目录</strong> 设置为<strong>777</strong>即可，这样就会自动创建一个 <strong>wp-config.php</strong> ，或者用 FTP 上传一个 <strong>wp-config.php</strong> 也可（该文件可参考 <strong>wp-config-sample.php</strong>）</a></p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/070011OFh.jpg">然 后，开始享受你的博客之旅吧！</a></p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/070011OFh.jpg">附：不知道是服务器的原因还是 <strong>RP问题</strong> ，我每次用 <strong>DA 控制面板</strong> 的空间，都得把几个关键目录设置成<strong>777</strong>，虽然后台很方面（修改主题、插件），但是难免 会有隐患。</a></p>
<p><a onclick="return hs.expand(this);" href="http://www.phpabc.cn/wp-content/uploads/images/2010/07/070011OFh.jpg">﻿</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpabc.cn/directadmin-mian-ban-kuai-su-an-zhuang-wordpress.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

