<?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>Life Studio &#187; 侧边栏</title>
	<atom:link href="http://wange.im/tag/sidebar/feed" rel="self" type="application/rss+xml" />
	<link>http://wange.im</link>
	<description>My Life, My Studio...</description>
	<lastBuildDate>Fri, 20 Jan 2012 01:49:17 +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 主题添加个性化小工具</title>
		<link>http://wange.im/add-widgets-for-wordpress.html</link>
		<comments>http://wange.im/add-widgets-for-wordpress.html#comments</comments>
		<pubDate>Sun, 16 Jan 2011 12:26:39 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[Widget]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[主题]]></category>
		<category><![CDATA[侧边栏]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4367</guid>
		<description><![CDATA[今天还是继续分解我现在的 WordPress 主题，这个主题都还没有写完美就开始拆分主题了，呵呵。如标题所言，今天分享的是给 WordPress 主题添加个性化的小工具这个方法。小工具我们大家都知道，在 WordPress 的后台中一般都默认自带了分类目录、文本、日历、近期评论这样一些小工具。但是有时候对于一款个性的 WordPress 主题来说，这些默认的小工具显然已经不能满足需求，所以我们需要自定义一些适合自己主题的小工具。有童鞋会说了，侧边栏上常用的功能可以直接把代码写进 sidebar 里嘛，何需小工具？但是对于不熟悉代码的小盆友来说，小工具要方便地多，而且小工具的拖动排序功能也是相当的便利。好了，废话说多了，下面切入正题，如何给自己的 WordPress 主题添加小工具。 只能作个示例，具体功能大家自己扩展了。把以下代码放入 WordPress 主题的 functions.php 中： class widget_test extends WP_Widget {     function widget_test() {         $widget_ops = array('description' =&#62; '小工具的描述信息');         $this-&#62;WP_Widget('widget_test', '小工具的标题', $widget_ops);     }     function widget($args, $instance) {         extract($args);         $title = apply_filters('widget_title', esc_attr($instance['title']));         $limit = strip_tags($instance['limit']); [...]]]></description>
			<content:encoded><![CDATA[<p>今天还是继续分解我现在的 WordPress 主题，这个主题都还没有写完美就开始拆分主题了，呵呵。如标题所言，今天分享的是给 WordPress 主题添加个性化的小工具这个方法。小工具我们大家都知道，在 WordPress 的后台中一般都默认自带了分类目录、文本、日历、近期评论这样一些小工具。但是有时候对于一款个性的 WordPress 主题来说，这些默认的小工具显然已经不能满足需求，所以我们需要自定义一些适合自己主题的小工具。有童鞋会说了，侧边栏上常用的功能可以直接把代码写进 sidebar 里嘛，何需小工具？但是对于不熟悉代码的小盆友来说，小工具要方便地多，而且小工具的拖动排序功能也是相当的便利。好了，废话说多了，下面切入正题，如何给自己的 WordPress 主题添加小工具。</p>
<p>只能作个示例，具体功能大家自己扩展了。把以下代码放入 WordPress 主题的 functions.php 中：</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000080; font-weight: bold;">class</span> <span style="color: #000000;">widget_test</span> <span style="color: #000080; font-weight: bold;">extends</span> <span style="color: #000000;">WP_Widget</span> <span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">widget_test</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000000;">$widget_ops</span> <span style="color: #000000;">=</span> <span style="color: #000000;">array</span>(<span style="color: #0000ff;">'description'</span> <span style="color: #000000;">=&gt;</span> <span style="color: #0000ff;">'小工具的描述信息'</span>);<br />
        <span style="color: #000000;">$this</span><span style="color: #000000;">-&gt;</span><span style="color: #000000;">WP_Widget</span>(<span style="color: #0000ff;">'widget_test'</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">'小工具的标题'</span><span style="color: #000000;">,</span> <span style="color: #000000;">$widget_ops</span>);<br />
    <span style="color: #000000;">}</span><br />
    <span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">widget</span>(<span style="color: #000000;">$args</span><span style="color: #000000;">,</span> <span style="color: #000000;">$instance</span>) <span style="color: #000000;">{</span><br />
        <span style="color: #000000;">extract</span>(<span style="color: #000000;">$args</span>);<br />
        <span style="color: #000000;">$title</span> <span style="color: #000000;">=</span> <span style="color: #000000;">apply_filters</span>(<span style="color: #0000ff;">'widget_title'</span><span style="color: #000000;">,</span> <span style="color: #000000;">esc_attr</span>(<span style="color: #000000;">$instance</span><span style="color: #000000;">[</span><span style="color: #0000ff;">'title'</span><span style="color: #000000;">]));</span><br />
        <span style="color: #000000;">$limit</span> <span style="color: #000000;">=</span> <span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">$instance</span><span style="color: #000000;">[</span><span style="color: #0000ff;">'limit'</span><span style="color: #000000;">]);</span><br />
        <span style="color: #000000;">echo</span> <span style="color: #000000;">$before_widget</span><span style="color: #000000;">.</span><span style="color: #000000;">$before_title</span><span style="color: #000000;">.</span><span style="color: #000000;">$title</span><span style="color: #000000;">.</span><span style="color: #000000;">$after_title</span>;<br />
        <span style="color: #000000;">echo</span> <span style="color: #0000ff;">'&lt;ul class="middleli"&gt;'</span>;<br />
            <span style="color: #000000;">test</span>( <span style="color: #000000;">$limit</span> );    <span style="font-style: italic; color: #008800;">//小工具需要执行的函数</span><br />
        <span style="color: #000000;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span>;<br />
        <span style="color: #000000;">echo</span> <span style="color: #000000;">$after_widget</span>;<br />
    <span style="color: #000000;">}</span><br />
    <span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">update</span>(<span style="color: #000000;">$new_instance</span><span style="color: #000000;">,</span> <span style="color: #000000;">$old_instance</span>) <span style="color: #000000;">{</span><br />
        <span style="color: #000080; font-weight: bold;">if</span> (<span style="color: #000000;">!</span><span style="color: #000000;">isset</span>(<span style="color: #000000;">$new_instance</span><span style="color: #000000;">[</span><span style="color: #0000ff;">'submit'</span><span style="color: #000000;">]))</span> <span style="color: #000000;">{</span><br />
            <span style="color: #000080; font-weight: bold;">return</span> <span style="color: #000080; font-weight: bold;">false</span>;<br />
        <span style="color: #000000;">}</span><br />
        <span style="color: #000000;">$instance</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$old_instance</span>;<br />
        <span style="color: #000000;">$instance</span><span style="color: #000000;">[</span><span style="color: #0000ff;">'title'</span><span style="color: #000000;">]</span> <span style="color: #000000;">=</span> <span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">$new_instance</span><span style="color: #000000;">[</span><span style="color: #0000ff;">'title'</span><span style="color: #000000;">]);</span><br />
        <span style="color: #000000;">$instance</span><span style="color: #000000;">[</span><span style="color: #0000ff;">'limit'</span><span style="color: #000000;">]</span> <span style="color: #000000;">=</span> <span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">$new_instance</span><span style="color: #000000;">[</span><span style="color: #0000ff;">'limit'</span><span style="color: #000000;">]);</span><br />
        <span style="color: #000080; font-weight: bold;">return</span> <span style="color: #000000;">$instance</span>;<br />
    <span style="color: #000000;">}</span><br />
    <span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">form</span>(<span style="color: #000000;">$instance</span>) <span style="color: #000000;">{</span><br />
        <span style="color: #000000;">global</span> <span style="color: #000000;">$wpdb</span>;<br />
        <span style="color: #000000;">$instance</span> <span style="color: #000000;">=</span> <span style="color: #000000;">wp_parse_args</span>((<span style="color: #000000;">array</span>) <span style="color: #000000;">$instance</span><span style="color: #000000;">,</span> <span style="color: #000000;">array</span>(<span style="color: #0000ff;">'title'</span> <span style="color: #000000;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">'limit'</span> <span style="color: #000000;">=&gt;</span> <span style="color: #0000ff;">''</span>));<br />
        <span style="color: #000000;">$title</span> <span style="color: #000000;">=</span> <span style="color: #000000;">esc_attr</span>(<span style="color: #000000;">$instance</span><span style="color: #000000;">[</span><span style="color: #0000ff;">'title'</span><span style="color: #000000;">]);</span><br />
        <span style="color: #000000;">$limit</span> <span style="color: #000000;">=</span> <span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">$instance</span><span style="color: #000000;">[</span><span style="color: #0000ff;">'limit'</span><span style="color: #000000;">]);</span><br />
<span style="color: #000000;">?&gt;</span><br />
        <span style="color: #000000;">&lt;</span>p<span style="color: #000000;">&gt;</span><br />
            <span style="color: #000000;">&lt;</span><span style="color: #000000;">label</span> <span style="color: #000080; font-weight: bold;">for</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;"</span><span style="color: #000000;">&gt;</span><span style="color: #a61717;">标题：</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">input</span> <span style="color: #000080; font-weight: bold;">class</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"widefat"</span> <span style="color: #000000;">id</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;?php echo $this-&gt;get_field_id('title'); ?&gt;"</span> <span style="color: #000000;">name</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;?php echo $this-&gt;get_field_name('title'); ?&gt;"</span> <span style="color: #000000;">type</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"text"</span> <span style="color: #000000;">value</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;?php echo $title; ?&gt;"</span> <span style="color: #000000;">/&gt;&lt;</span><span style="color: #a61717;">/label&gt;</span><br />
        <span style="color: #000000;">&lt;</span><span style="color: #a61717;">/p&gt;</span><br />
        <span style="color: #000000;">&lt;</span>p<span style="color: #000000;">&gt;</span><br />
            <span style="color: #000000;">&lt;</span><span style="color: #000000;">label</span> <span style="color: #000080; font-weight: bold;">for</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;?php echo $this-&gt;get_field_id('limit'); ?&gt;"</span><span style="color: #000000;">&gt;</span><span style="color: #a61717;">数量：</span><span style="color: #000000;">&lt;</span><span style="color: #000000;">input</span> <span style="color: #000080; font-weight: bold;">class</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"widefat"</span> <span style="color: #000000;">id</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;?php echo $this-&gt;get_field_id('limit'); ?&gt;"</span> <span style="color: #000000;">name</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;?php echo $this-&gt;get_field_name('limit'); ?&gt;"</span> <span style="color: #000000;">type</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"text"</span> <span style="color: #000000;">value</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;?php echo $limit; ?&gt;"</span> <span style="color: #000000;">/&gt;&lt;</span><span style="color: #a61717;">/label&gt;</span><br />
        <span style="color: #000000;">&lt;</span><span style="color: #a61717;">/p&gt;</span><br />
        <span style="color: #000000;">&lt;</span><span style="color: #000000;">input</span> <span style="color: #000000;">type</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"hidden"</span> <span style="color: #000000;">id</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;?php echo $this-&gt;get_field_id('submit'); ?&gt;"</span> <span style="color: #000000;">name</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"&lt;?php echo $this-&gt;get_field_name('submit'); ?&gt;"</span> <span style="color: #000000;">value</span><span style="color: #000000;">=</span><span style="color: #0000ff;">"1"</span> <span style="color: #000000;">/&gt;</span><br />
<span style="color: #000000;">&lt;?</span><span style="color: #000000;">php</span><br />
    <span style="color: #000000;">}</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">add_action</span>(<span style="color: #0000ff;">'widgets_init'</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">'widget_test_init'</span>);<br />
<span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">widget_test_init</span>() <span style="color: #000000;">{</span><br />
    <span style="color: #000000;">register_widget</span>(<span style="color: #0000ff;">'widget_test'</span>);<br />
<span style="color: #000000;">}</span></div>
<p>就是这样，一步到位，保存之后再去你的小工具里看一下，是不是多了一个叫“小工具的标题”的小工具呀？注意到上面代码的 test( $limit ); 这个就是你需要小工具执行的函数，你可以直接写在这里面，也可以把函数写到 functions.php 里，都一样。</p>
<p>下面这张图是我自己主题所用到的万戈牌小工具，以后要改顺序也不用修改主题了，拖动就OK了，哈哈哈哈，真方便。<strong style="color: red;">点击看大图</strong>哟~~<br />
<a href="http://wange.im/images/widgets.jpg" target="_blank"><img src="http://wange.im/images/widgets.jpg" alt="" width="500" height="244" /></a></p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/widget/" title="Widget" rel="tag">Widget</a>,<a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a>,<a href="http://wange.im/tag/theme/" title="主题" rel="tag">主题</a>,<a href="http://wange.im/tag/sidebar/" title="侧边栏" rel="tag">侧边栏</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/unregister-widget-in-wordpress.html" rel="bookmark" title="移除 Wordpress 中的指定小工具">移除 Wordpress 中的指定小工具</a>        <div class="rl_date">2011年01月5日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/readerwall-on-sidebar-without-plugins.html" rel="bookmark" title="Wordpress 免插件版侧边栏读者墙">Wordpress 免插件版侧边栏读者墙</a>        <div class="rl_date">2009年10月24日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/calendar.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="美化 Wordpress 之日历样式" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wordpress-landscaping-style-of-the-calendar.html" rel="bookmark" title="美化 Wordpress 之日历样式">美化 Wordpress 之日历样式</a>        <div class="rl_date">2009年08月9日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/different-sidebar-in-different-pages.html" rel="bookmark" title="Wordpress 不同页面调用不同侧边栏">Wordpress 不同页面调用不同侧边栏</a>        <div class="rl_date">2009年07月11日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/add-widgets-for-wordpress.html/feed</wfw:commentRss>
		<slash:comments>175</slash:comments>
		</item>
		<item>
		<title>jQuery 之关闭/显示侧边栏</title>
		<link>http://wange.im/close-show-sidebar-width-jquery.html</link>
		<comments>http://wange.im/close-show-sidebar-width-jquery.html#comments</comments>
		<pubDate>Wed, 18 Aug 2010 13:27:54 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[转来载去]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[侧边栏]]></category>

		<guid isPermaLink="false">http://wange.im/?p=3696</guid>
		<description><![CDATA[大家不用找了，这个效果我没有用在自己的博客上，只是在本地测试玩的，因为感觉代码简单，但是效果很不错，所以就从木木那里照搬过来了。木木称之为“关闭/显示侧边栏”完美终结版，不过我觉得如果能加上 Cookies 记录访客的行为，那就更完美了，再不过，如果是我的话，也不用 Cookies 记录，因为这个效果仅作点缀而已，没必要再多加几行脚本。下面贴代码。 1.载入 jQuery 木木提供了 jQuery1.4 版本下的方法，对我来说 jQuery1.4太过庞大，还是免了，咱们用大众版本的就可以了。 2、执行脚本 $('#close-sidebar').toggle(function(){     $(this).text("显示侧边栏");     $('#sidebar').hide();     $('#content').animate({width: "960px"}, 1000);     },function(){     $(this).text("关闭侧边栏");     $('#sidebar').delay(800).show(0);     $('#content').animate({width: "705px"}, 800); }); 还是比较容易理解的，就不多解释了。 3、关闭/显示侧边栏的按钮 &#60;a id="close-sidebar" href="javascript:void(0)"&#62;关闭侧边栏&#60;/a&#62; 一般放在头部的导航栏就可以吧。 木帅的原文在此：http://immmmm.com/close-show-sidebar-prefect-code.html，或许在不久后上市的新主题，大家可以看到我用的这个效果，敬请期待～ 与 jQuery,侧边栏 相关的文章 JQuery 实现带滑动层的图片展示效果 2010年02月24日 Wordpress 之链接平移 JQuery 特效 2010年02月19日 基于 jQuery 的图片/文字无缝滚动 2011年12月20日 jQuery [...]]]></description>
			<content:encoded><![CDATA[<p>大家不用找了，这个效果我没有用在自己的博客上，只是在本地测试玩的，因为感觉代码简单，但是效果很不错，所以就从<a title="“关闭/显示侧边栏”完美终结版" rel="external nofollow" href="http://immmmm.com/close-show-sidebar-prefect-code.html" target="_blank">木木</a>那里照搬过来了。木木称之为“关闭/显示侧边栏”完美终结版，不过我觉得如果能加上 Cookies 记录访客的行为，那就更完美了，再不过，如果是我的话，也不用 Cookies 记录，因为这个效果仅作点缀而已，没必要再多加几行脚本。下面贴代码。</p>
<p>1.载入 jQuery</p>
<p>木木提供了 jQuery1.4 版本下的方法，对我来说 jQuery1.4太过庞大，还是免了，咱们用大众版本的就可以了。</p>
<p>2、执行脚本</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#close-sidebar'</span><span style="color: #000000;">).</span><span style="color: #000000;">toggle</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">text</span>(<span style="color: #0000ff;">"显示侧边栏"</span>);<br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#sidebar'</span><span style="color: #000000;">).</span><span style="color: #000000;">hide</span>();<br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#content'</span><span style="color: #000000;">).</span><span style="color: #000000;">animate</span><span style="color: #000000;">({</span><span style="color: #000000;">width</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">"960px"</span><span style="color: #000000;">},</span> <span style="color: #0000ff;">1000</span>);<br />
    <span style="color: #000000;">},</span><span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">text</span>(<span style="color: #0000ff;">"关闭侧边栏"</span>);<br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#sidebar'</span><span style="color: #000000;">).</span><span style="color: #000000;">delay</span>(<span style="color: #0000ff;">800</span><span style="color: #000000;">).</span><span style="color: #000000;">show</span>(<span style="color: #0000ff;">0</span>);<br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#content'</span><span style="color: #000000;">).</span><span style="color: #000000;">animate</span><span style="color: #000000;">({</span><span style="color: #000000;">width</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">"705px"</span><span style="color: #000000;">},</span> <span style="color: #0000ff;">800</span>);<br />
<span style="color: #000000;">});</span></div>
<p>还是比较容易理解的，就不多解释了。</p>
<p>3、关闭/显示侧边栏的按钮</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;a</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"close-sidebar"</span> <span style="color: #ff0000;">href=</span><span style="color: #0000ff;">"javascript:void(0)"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">关闭侧边栏</span><span style="color: #000080; font-weight: bold;">&lt;/a&gt;</span></div>
<p>一般放在头部的导航栏就可以吧。</p>
<p>木帅的原文在此：<a title="“关闭/显示侧边栏”完美终结版" href="http://immmmm.com/close-show-sidebar-prefect-code.html" target="_blank">http://immmmm.com/close-show-sidebar-prefect-code.html</a>，或许在不久后上市的新主题，大家可以看到我用的这个效果，敬请期待～</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/sidebar/" title="侧边栏" rel="tag">侧边栏</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-slide-pic-show.html" rel="bookmark" title="JQuery 实现带滑动层的图片展示效果">JQuery 实现带滑动层的图片展示效果</a>        <div class="rl_date">2010年02月24日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/mouseover-link-slide-for-wordpress.html" rel="bookmark" title="Wordpress 之链接平移 JQuery 特效">Wordpress 之链接平移 JQuery 特效</a>        <div class="rl_date">2010年02月19日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/marquee-scroll.html" rel="bookmark" title="基于 jQuery 的图片/文字无缝滚动">基于 jQuery 的图片/文字无缝滚动</a>        <div class="rl_date">2011年12月20日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-highslide-on-demand.html" rel="bookmark" title="jQuery 按需加载 HighSlide 效果">jQuery 按需加载 HighSlide 效果</a>        <div class="rl_date">2011年10月10日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/close-show-sidebar-width-jquery.html/feed</wfw:commentRss>
		<slash:comments>95</slash:comments>
		</item>
		<item>
		<title>WordPress 非插件统计网站访问信息</title>
		<link>http://wange.im/wordpress-ip-statistics-without-plugins.html</link>
		<comments>http://wange.im/wordpress-ip-statistics-without-plugins.html#comments</comments>
		<pubDate>Sat, 10 Apr 2010 13:47:43 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[侧边栏]]></category>
		<category><![CDATA[统计]]></category>
		<category><![CDATA[非插件]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2988</guid>
		<description><![CDATA[前段时间，写了一篇《WordPress 非插件统计网站信息》，是对 WordPress 的日志总数、草稿总数、评论总数、用户总数等 WordPress 内置的函数对 WordPress 本身的信息进行统计，从而代替 WP  statistics 这类统计插件。今天又折腾出了姐妹篇，同样是非插件的方法，对网站的当日访问量、昨日访问量、访问 IP 总计、同一 IP 访问次数以及同时在线人数进行统计。 我参考了网站其他朋友的实现方法，大多数是用到数据库的，这个我不熟悉，试了几次都没成功，而且我的 WordPress 用上了 object cache 数据库缓存，会造成显示的统计数据不准确的情况。所以换上了纯 PHP 统计网站仿问信息的方法。 说了大半天，还是先来看看效果吧，请见小站内页侧边栏“网站统计”部分，其中的今日访问和当前在线就是本文提到的方法和效果，当然我只是用了其中的一部分，更多完整的效果请见附图。 方法如下： 1、下载 count.rar，上传并解压到主题文件夹下。 count.rar 中有四个文件，一个 count.php 和三个没有后缀名的临时文件，用来存放统计 log，所以请保持这三个没有后缀名的临时文件可写，至少要 755。 2、在需要显示统计信息的地方插入 &#60;script src="count.php"&#62;&#60;/script&#62; 来调用前面的 count.php，这里要注意路径。 关于代码，我就不分析了，有兴趣的朋友可以研究一下，至于样式大家也发挥自己的想象力吧。另外这统计的准不准确，我也说不上来，因为今天晚上才刚刚放上这个功能，还有待时间的考验，请大家帮忙一起测试啦。 与 WordPress,侧边栏,统计,非插件 相关的文章 Wordpress 非插件统计网站信息 2010年03月20日 万戈牌 Fuck IE6 非插件版 2011年05月13日 非插件同步 WordPress 日志到嘀咕 2011年03月31日 阻止 [...]]]></description>
			<content:encoded><![CDATA[<p>前段时间，写了一篇《<a title="Wordpress 非插件统计网站信息" href="http://wange.im/wordpress-statistics-without-plugins.html">WordPress 非插件统计网站信息</a>》，是对 WordPress 的日志总数、草稿总数、评论总数、用户总数等 WordPress 内置的函数对 WordPress 本身的信息进行统计，从而代替 WP  statistics 这类统计插件。今天又折腾出了姐妹篇，同样是非插件的方法，对网站的当日访问量、昨日访问量、访问 IP 总计、同一 IP 访问次数以及同时在线人数进行统计。</p>
<p>我参考了网站其他朋友的实现方法，大多数是用到数据库的，这个我不熟悉，试了几次都没成功，而且我的 WordPress 用上了 <a title="启用 WordPress object-cache 缓存" href="http://wange.im/wordpress-object-cache.html">object cache 数据库缓存</a>，会造成显示的统计数据不准确的情况。所以换上了纯 PHP 统计网站仿问信息的方法。</p>
<p>说了大半天，还是先来看看效果吧，请见小站内页侧边栏“网站统计”部分，其中的今日访问和当前在线就是本文提到的方法和效果，当然我只是用了其中的一部分，更多完整的效果请见附图。</p>
<p><img src="http://7tlzlq.bay.livefilestore.com/y1pUEXECtHauGkfgfP_NvNNdtyHRSTLPzEjHOmH7XaFE1ZJEbXffeMh3nZRekwN0W6IigRSx50BIH2GpsXC3LyGVmDjhDel3Zpa/statistics.jpg" alt="" /></p>
<p>方法如下：</p>
<p>1、下载 <a title="count" href="http://wange.im/wp-content/uploads/2010/04/count.rar">count.rar</a>，上传并解压到主题文件夹下。</p>
<p>count.rar 中有四个文件，一个 count.php 和三个没有后缀名的临时文件，用来存放统计 log，所以请保持这三个没有后缀名的临时文件可写，至少要 755。</p>
<p>2、在需要显示统计信息的地方插入 &lt;script src="count.php"&gt;&lt;/script&gt; 来调用前面的 count.php，这里要注意路径。</p>
<p>关于代码，我就不分析了，有兴趣的朋友可以研究一下，至于样式大家也发挥自己的想象力吧。另外这统计的准不准确，我也说不上来，因为今天晚上才刚刚放上这个功能，还有待时间的考验，请大家帮忙一起测试啦。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a>,<a href="http://wange.im/tag/sidebar/" title="侧边栏" rel="tag">侧边栏</a>,<a href="http://wange.im/tag/statistics/" title="统计" rel="tag">统计</a>,<a href="http://wange.im/tag/no-plugins/" title="非插件" rel="tag">非插件</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wordpress-statistics-without-plugins.html" rel="bookmark" title="Wordpress 非插件统计网站信息">Wordpress 非插件统计网站信息</a>        <div class="rl_date">2010年03月20日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wg-ie6warn-without-plugins.html" rel="bookmark" title="万戈牌 Fuck IE6 非插件版">万戈牌 Fuck IE6 非插件版</a>        <div class="rl_date">2011年05月13日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/digu.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="非插件同步 WordPress 日志到嘀咕" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/sync-wordpress-to-digu.html" rel="bookmark" title="非插件同步 WordPress 日志到嘀咕">非插件同步 WordPress 日志到嘀咕</a>        <div class="rl_date">2011年03月31日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/no-self-ping-in-wordpress.html" rel="bookmark" title="阻止 Wordpress 对站内文章的 pingback">阻止 Wordpress 对站内文章的 pingback</a>        <div class="rl_date">2011年03月28日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/wordpress-ip-statistics-without-plugins.html/feed</wfw:commentRss>
		<slash:comments>135</slash:comments>
		</item>
		<item>
		<title>广告恒久远，一个永流传～</title>
		<link>http://wange.im/ask-for-ads.html</link>
		<comments>http://wange.im/ask-for-ads.html#comments</comments>
		<pubDate>Sat, 27 Mar 2010 12:36:54 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[三言两语]]></category>
		<category><![CDATA[侧边栏]]></category>
		<category><![CDATA[广告]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2898</guid>
		<description><![CDATA[上一次招广告的效果相当好，发布之后第二天、第三天就连续卖出去两个广告位，看来我写文章本身就是一种很好的广告呀，HOHO～嗯嗯，其实我也可以考虑一下写有偿软文，应该收入也不错嘛，哈呀，想钱想疯掉了。 跑题之前赶快回归本文正题，今天就再奢侈一次，腾出一篇文章来介绍我新添加的广告位，就是评论框位置的右侧，其实这个广告位已经添加了一周了，因为没有好好推广，所以少人问津，只有猴猴问过，可惜就木有下文了…… 一号广告位： 位置 所有日志页评论框右侧 格式与尺寸 125px × 125px 图片 价格 一口价 50大洋/月 支付方式 支付宝 申明 1、非法广告不接 2、瘦身美容广告不接 3、看不顺眼的广告不接 4、预付款 5、图片自备 6、谢绝试用期 7、支持图片标题和描述 8、最终解释权归万戈所有 示例   关于这个广告位的评价，个人感觉绝对是黄金位置啊，至少每个留言和有翻看留言习惯的朋友都会看到这则广告位吧，于是定了50元/月试试水，卖的好就再涨价，哈哈。再来看看 smigoo MM 对此广告位的客观评价吧： 二号广告位 位置 首页侧边栏（暂时提供两个） 格式与尺寸 165px × 165px 图片 价格 一口价——80大洋/月 支付方式 支付宝 申明 1、非法广告不接 2、瘦身美容广告不接 3、看不顺眼的广告不接 4、预付款 5、图片自备 6、谢绝试用期 7、支持图片标题和描述（描述中仅限单个外链，增加外链需10元/月/个） 8、最终解释权归万戈所有 示例   这个效果可以见我的内页啦，因为首页暂时没有人买，我就先不挂了，你可以选择小张那样带滑动层的 JQuery [...]]]></description>
			<content:encoded><![CDATA[<p>上一次<a title="招、招、招广告啦～～～" href="http://wange.im/ads-for-sale.html">招广告</a>的效果相当好，发布之后第二天、第三天就连续卖出去两个广告位，看来我写文章本身就是一种很好的广告呀，HOHO～嗯嗯，其实我也可以考虑一下写有偿软文，应该收入也不错嘛，哈呀，想钱想疯掉了。</p>
<p>跑题之前赶快回归本文正题，今天就再奢侈一次，腾出一篇文章来介绍我新添加的广告位，就是评论框位置的右侧，其实这个广告位已经添加了一周了，因为没有好好推广，所以少人问津，只有<a title="猴子's Weblog" href="http://www.houzi.in/" target="_blank">猴猴</a>问过，可惜就木有下文了……</p>
<p><span id="ad1" style="font-weight: 700;text-decoration: line-through;">一号广告位：</span></p>
<table class="table" border="1" width="500" align="center">
<tbody>
<tr>
<td width="80"><strong>位置</strong></td>
<td>所有日志页评论框右侧</td>
</tr>
<tr>
<td><strong>格式与尺寸</strong></td>
<td>125px × 125px 图片</td>
</tr>
<tr>
<td><strong>价格</strong></td>
<td>一口价 50大洋/月</td>
</tr>
<tr>
<td><strong>支付方式</strong></td>
<td>支付宝</td>
</tr>
<tr>
<td><strong>申明</strong></td>
<td>1、非法广告不接<br />
2、瘦身美容广告不接<br />
3、看不顺眼的广告不接<br />
4、预付款<br />
5、图片自备<br />
6、谢绝试用期<br />
7、支持图片标题和描述<br />
8、最终解释权归万戈所有</td>
</tr>
<tr>
<td><strong>示例</strong></td>
<td> <img src="http://sajfiw.bay.livefilestore.com/y1p2o64_u6LmROkLD5A8yt1SNMlkBx0UI-M68cWn2u4HimgqJPDW4iOhtq9oJt9otNQobpzoDOwDf05Qj2chqf0wrXTp8tw7ecK/ad1.jpg" alt="" /></td>
</tr>
</tbody>
</table>
<p>关于这个广告位的评价，个人感觉绝对是黄金位置啊，至少每个留言和有翻看留言习惯的朋友都会看到这则广告位吧，于是定了50元/月试试水，卖的好就再涨价，哈哈。再来看看 smigoo MM 对此广告位的客观评价吧：</p>
<p style="text-align: center;"><img class="aligncenter" src="http://sajfiw.bay.livefilestore.com/y1pHX0hRJbEUVL4BXnpPBcgII4Hg9WhbQHXSHVG-3RMCl0dk_7Dxikc9Oi6lFGVmIZUfKuadU4aj4JT48EFDnyb1gi4ZwUroMrv/smigoo.jpg" alt="" /></p>
<p><span id="ad2" style="font-weight: 700;">二号广告位</span></p>
<table class="table" border="1" width="500" align="center">
<tbody>
<tr>
<td><strong>位置</strong></td>
<td>首页侧边栏（暂时提供两个）</td>
</tr>
<tr>
<td><strong>格式与尺寸</strong></td>
<td>165px × 165px 图片</td>
</tr>
<tr>
<td><strong>价格</strong></td>
<td>一口价——80大洋/月</td>
</tr>
<tr>
<td><strong>支付方式</strong></td>
<td>支付宝</td>
</tr>
<tr>
<td><strong>申明</strong></td>
<td>1、非法广告不接<br />
2、瘦身美容广告不接<br />
3、看不顺眼的广告不接<br />
4、预付款<br />
5、图片自备<br />
6、谢绝试用期<br />
7、支持图片标题和描述（描述中仅限单个外链，增加外链需10元/月/个）<br />
8、最终解释权归万戈所有</td>
</tr>
<tr>
<td><strong>示例</strong></td>
<td> <img src="http://public.bay.livefilestore.com/y1pUrL5hUVt16w6rPBHbuNABabLhAKBV_LrwlhtDFnURYpd5_YawQB-ZZgG_5wEQA9EP3ee29TLwOO-3LrJ6MX23A/ad2.jpg" alt="" /><img src="http://public.bay.livefilestore.com/y1pSaIBoUR4nBkk5LpzT75olcQloG_QJizrrwc1AePGXoQsm36PHElEM7JDU5iHvNfhaP7PIWYbaH6bCungsFh55g/ad3.jpg" alt="" /></td>
</tr>
</tbody>
</table>
<p>这个效果可以见我的内页啦，因为首页暂时没有人买，我就先不挂了，你可以选择小张那样<a title="JQuery 实现带滑动层的图片展示效果" href="http://wange.im/jquery-slide-pic-show.html">带滑动层的 JQuery 特效</a>的，当然也可以选煎蛋那种纯图片的。PS：顺便 BS 一下下<a title="我要说" href="http://wyshuo.com" target="_blank">星网</a>童鞋，上次拍了我首页的广告居然不买，等我首页广告卖出去了，用钱砸你 T_T</p>
<p>PS1：感谢国家，感谢博友，感谢自己，第一次单月网赚收入破四位数了，鼓掌～</p>
<p>PS2：今天是地球一小时日，我响应一下，关手机了～～</p>
<p>PS3：不知道超人童鞋今天能否创下沙发五连贯的新记录呢～～～</p>
<p>PS4：嗯，刚想好又忘记了～～～～</p>
<p>PS5：本文发布的一小时后，一号广告位已被裸哥 <a title="刘易俊" href="http://liuyijun.com/" target="_blank">619</a> 轻松拿下，还剩二号广告位，来抢吧～～～～～</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/sidebar/" title="侧边栏" rel="tag">侧边栏</a>,<a href="http://wange.im/tag/ad/" title="广告" rel="tag">广告</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/mood.jpg" alt="三言两语" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/ads-for-sale.html" rel="bookmark" title="招、招、招广告啦～～～">招、招、招广告啦～～～</a>        <div class="rl_date">2010年03月2日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/mood.jpg" alt="三言两语" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-slide-pic-show.html" rel="bookmark" title="JQuery 实现带滑动层的图片展示效果">JQuery 实现带滑动层的图片展示效果</a>        <div class="rl_date">2010年02月24日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/nuffnang.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="拿福能千人挑战有奖活动" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/nuffnang-challenge-1000.html" rel="bookmark" title="拿福能千人挑战有奖活动">拿福能千人挑战有奖活动</a>        <div class="rl_date">2011年05月23日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/img_1304835725_15.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="拿福能博主北京聚会" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/nuffnang-beijing-party.html" rel="bookmark" title="拿福能博主北京聚会">拿福能博主北京聚会</a>        <div class="rl_date">2011年05月8日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/ask-for-ads.html/feed</wfw:commentRss>
		<slash:comments>186</slash:comments>
		</item>
		<item>
		<title>WordPress 非插件统计网站信息</title>
		<link>http://wange.im/wordpress-statistics-without-plugins.html</link>
		<comments>http://wange.im/wordpress-statistics-without-plugins.html#comments</comments>
		<pubDate>Sat, 20 Mar 2010 12:20:42 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[侧边栏]]></category>
		<category><![CDATA[统计]]></category>
		<category><![CDATA[非插件]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2864</guid>
		<description><![CDATA[这里说的 WordPress 网站统计信息不是只 IP、PV 这类的流量信息，而是指 WordPress 日志数量、评论数量、页面、分类等等的统计信息，以前看到过别人用 WP  statistics 这类的插件来实现这个功能，不过了解我的朋友们都应该知道啦，我的原则是能用代码搞定的就决不用插件解决，所以今天又折腾了用非插件来显示网站统计信息的功能。 1、日志总数： &#60;?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts-&#62;publish;?&#62; 2、草稿数目： &#60;?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts-&#62;draft; ?&#62; 3、评论总数： &#60;?php echo $wpdb-&#62;get_var(&#34;SELECT COUNT(*) FROM $wpdb-&#62;comments&#34;);?&#62; 4、成立时间： &#60;?php echo floor((time()-strtotime(&#34;2008-8-18&#34;))/86400); ?&#62; 5、标签总数： &#60;?php echo $count_tags = wp_count_terms(&#39;post_tag&#39;); ?&#62; 6、页面总数： &#60;?php $count_pages = wp_count_posts(&#39;page&#39;); echo $page_posts [...]]]></description>
			<content:encoded><![CDATA[<p>这里说的 WordPress 网站统计信息不是只 IP、PV 这类的流量信息，而是指 WordPress 日志数量、评论数量、页面、分类等等的统计信息，以前看到过别人用 WP  statistics 这类的插件来实现这个功能，不过了解我的朋友们都应该知道啦，我的原则是能用代码搞定的就决不用插件解决，所以今天又折腾了用非插件来显示网站统计信息的功能。</p>
<p>1、日志总数：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1269086395843="14"><SPAN style="COLOR: #008080">&lt;?php</SPAN> <SPAN style="COLOR: #000000">$count_posts</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">wp_count_posts</SPAN>(); <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">echo</SPAN> <SPAN style="COLOR: #000000">$published_posts</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$count_posts</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #ff0000">publish</SPAN>;<SPAN style="COLOR: #008080">?&gt;</SPAN><BR></DIV></p>
<p>2、草稿数目：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1269086486796="14"><SPAN style="COLOR: #008080">&lt;?php</SPAN> <SPAN style="COLOR: #000000">$count_posts</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">wp_count_posts</SPAN>(); <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">echo</SPAN> <SPAN style="COLOR: #000000">$draft_posts</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$count_posts</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #ff0000">draft</SPAN>; <SPAN style="COLOR: #008080">?&gt;</SPAN><BR></DIV></p>
<p>3、评论总数：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1269086577531="14"><SPAN style="COLOR: #008080">&lt;?php</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">echo</SPAN> <SPAN style="COLOR: #000000">$wpdb</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #ff0000">get_var</SPAN>(<SPAN style="COLOR: #0000ff">&quot;SELECT COUNT(*) FROM </SPAN><SPAN style="COLOR: #0000ff">$wpdb-&gt;comments</SPAN><SPAN style="COLOR: #0000ff">&quot;</SPAN>);<SPAN style="COLOR: #008080">?&gt;</SPAN><BR></DIV></p>
<p>4、成立时间：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1269086651640="14"><SPAN style="COLOR: #008080">&lt;?php</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">echo</SPAN> <SPAN style="COLOR: #000000">floor</SPAN>((<SPAN style="COLOR: #000000">time</SPAN>()<SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">strtotime</SPAN>(<SPAN style="COLOR: #0000ff">&quot;2008-8-18&quot;</SPAN>))<SPAN style="COLOR: #000000">/</SPAN><SPAN style="COLOR: #0000ff">86400</SPAN>); <SPAN style="COLOR: #008080">?&gt;</SPAN><BR></DIV></p>
<p>5、标签总数：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1269086696796="14"><SPAN style="COLOR: #008080">&lt;?php</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">echo</SPAN> <SPAN style="COLOR: #000000">$count_tags</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">wp_count_terms</SPAN>(<SPAN style="COLOR: #0000ff">&#39;post_tag&#39;</SPAN>); <SPAN style="COLOR: #008080">?&gt;</SPAN><BR></DIV></p>
<p>6、页面总数：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1269086756296="14"><SPAN style="COLOR: #008080">&lt;?php</SPAN> <SPAN style="COLOR: #000000">$count_pages</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">wp_count_posts</SPAN>(<SPAN style="COLOR: #0000ff">&#39;page&#39;</SPAN>); <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">echo</SPAN> <SPAN style="COLOR: #000000">$page_posts</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$count_pages</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #ff0000">publish</SPAN>; <SPAN style="COLOR: #008080">?&gt;</SPAN><BR></DIV></p>
<p>7、分类总数：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1269086808890="14"><SPAN style="COLOR: #008080">&lt;?php</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">echo</SPAN> <SPAN style="COLOR: #000000">$count_categories</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">wp_count_terms</SPAN>(<SPAN style="COLOR: #0000ff">&#39;category&#39;</SPAN>); <SPAN style="COLOR: #008080">?&gt;</SPAN><BR></DIV></p>
<p>8、链接总数：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1269086858000="14"><SPAN style="COLOR: #008080">&lt;?php</SPAN> <SPAN style="COLOR: #000000">$link</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$wpdb</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #ff0000">get_var</SPAN>(<SPAN style="COLOR: #0000ff">&quot;SELECT COUNT(*) FROM </SPAN><SPAN style="COLOR: #0000ff">$wpdb-&gt;links</SPAN><SPAN style="COLOR: #0000ff"> WHERE link_visible = &#39;Y&#39;&quot;</SPAN>); <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">echo</SPAN> <SPAN style="COLOR: #000000">$link</SPAN>; <SPAN style="COLOR: #008080">?&gt;</SPAN><BR></DIV></p>
<p>9、用户总数：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1269086901937="14"><SPAN style="COLOR: #008080">&lt;?php</SPAN> <SPAN style="COLOR: #000000">$users</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$wpdb</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #ff0000">get_var</SPAN>(<SPAN style="COLOR: #0000ff">&quot;SELECT COUNT(ID) FROM </SPAN><SPAN style="COLOR: #0000ff">$wpdb-&gt;users</SPAN><SPAN style="COLOR: #0000ff">&quot;</SPAN>); <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">echo</SPAN> <SPAN style="COLOR: #000000">$users</SPAN>; <SPAN style="COLOR: #008080">?&gt;</SPAN><BR></DIV></p>
<p>10、最后更新：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1269086960375="14"><SPAN style="COLOR: #008080">&lt;?php</SPAN> <SPAN style="COLOR: #000000">$last</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">$wpdb</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #ff0000">get_results</SPAN>(<SPAN style="COLOR: #0000ff">&quot;SELECT MAX(post_modified) AS MAX_m FROM </SPAN><SPAN style="COLOR: #0000ff">$wpdb-&gt;posts</SPAN><SPAN style="COLOR: #0000ff"> WHERE (post_type = &#39;post&#39; OR post_type = 'page') AND (post_status = 'publish' OR post_status = 'private')&quot;</SPAN>);<SPAN style="COLOR: #000000">$last</SPAN> <SPAN style="COLOR: #000000">=</SPAN> <SPAN style="COLOR: #000000">date</SPAN>(<SPAN style="COLOR: #0000ff">&#39;Y-n-j&#39;</SPAN><SPAN style="COLOR: #000000">,</SPAN> <SPAN style="COLOR: #000000">strtotime</SPAN>(<SPAN style="COLOR: #000000">$last</SPAN><SPAN style="COLOR: #000000">[</SPAN><SPAN style="COLOR: #0000ff">0</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">-&gt;</SPAN><SPAN style="COLOR: #ff0000">MAX_m</SPAN>));<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">echo</SPAN> <SPAN style="COLOR: #000000">$last</SPAN>; <SPAN style="COLOR: #008080">?&gt;</SPAN><BR></DIV></p>
<p>效果可以看我的侧边栏，我没有全部用上，只选了其中六个。</p>
<p>方法来源：<a href="http://sunsunsun.org/wordpress/wp-tutorials/also-get-rid-of-a-plugin-wordpress-statistics-code.html" target="_blank">http://sunsunsun.org/wordpress/wp-tutorials/also-get-rid-of-a-plugin-wordpress-statistics-code.html</a></p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a>,<a href="http://wange.im/tag/sidebar/" title="侧边栏" rel="tag">侧边栏</a>,<a href="http://wange.im/tag/statistics/" title="统计" rel="tag">统计</a>,<a href="http://wange.im/tag/no-plugins/" title="非插件" rel="tag">非插件</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/statistics.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="Wordpress 非插件统计网站访问信息" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wordpress-ip-statistics-without-plugins.html" rel="bookmark" title="Wordpress 非插件统计网站访问信息">Wordpress 非插件统计网站访问信息</a>        <div class="rl_date">2010年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wg-ie6warn-without-plugins.html" rel="bookmark" title="万戈牌 Fuck IE6 非插件版">万戈牌 Fuck IE6 非插件版</a>        <div class="rl_date">2011年05月13日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/digu.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="非插件同步 WordPress 日志到嘀咕" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/sync-wordpress-to-digu.html" rel="bookmark" title="非插件同步 WordPress 日志到嘀咕">非插件同步 WordPress 日志到嘀咕</a>        <div class="rl_date">2011年03月31日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/no-self-ping-in-wordpress.html" rel="bookmark" title="阻止 Wordpress 对站内文章的 pingback">阻止 Wordpress 对站内文章的 pingback</a>        <div class="rl_date">2011年03月28日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/wordpress-statistics-without-plugins.html/feed</wfw:commentRss>
		<slash:comments>112</slash:comments>
		</item>
		<item>
		<title>指定 WordPress 显示一段时间内的文章</title>
		<link>http://wange.im/display-article-in-a-period-of-time-in-wordpress.html</link>
		<comments>http://wange.im/display-article-in-a-period-of-time-in-wordpress.html#comments</comments>
		<pubDate>Mon, 15 Mar 2010 11:58:05 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[侧边栏]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2845</guid>
		<description><![CDATA[可能是我最近水文太多，也可能是我疏于互访，近日我的 WordPress 人气一落千丈，大不如从前。看着侧边栏的“点击最高”和“热评日志”中的文章，已经好久没有赶超上来的文章，翻来翻去就这么几篇，对我来说是一种侧面打击，而且无论从用户体验、用户粘度或者 SEO 的角度来说都并不太好，所以今天在“点击最高”和“热评日志”的函数上做了些小小的手脚，加上了时间范围，让这两个版块上显示近一个月内的文章，那样就会有不断的新鲜文章更替上来。 正好，有两种限制时间范围的方法，我就分别介绍一下啦。 方法一：在 WordPress 主题的相关函数中找到 where 条件句，在其中加上一句条件句：post_date &#62; date_sub( NOW(), INTERVAL 1 MONTH )，这个具体什么意思我就不解释了，还是很好理解的嘛，顺便拿自己的“点击最高”的代码作个例子，仅作参考哟，因为需要插件配合，不是通用的。 &#60;?php function hot_posts($limit = 10, $cut_off = 0, $before='&#60;li&#62;', $after='&#60;/li&#62;'){ global $wpdb; $home = get_option('siteurl'); $lastXs = $wpdb-&#62;get_results("SELECT ".$wpdb-&#62;posts.".ID AS ID,".$wpdb-&#62;posts.".post_title AS TITLE ,".$wpdb-&#62;post_counter.".post_count AS ZAEHLER FROM ".$wpdb-&#62;posts.",".$wpdb-&#62;post_counter." where ".$wpdb-&#62;post_counter.".post_id = ".$wpdb-&#62;posts.".ID AND post_type = 'post' AND [...]]]></description>
			<content:encoded><![CDATA[<p>可能是我最近水文太多，也可能是我疏于互访，近日我的 WordPress 人气一落千丈，大不如从前。看着侧边栏的“点击最高”和“热评日志”中的文章，已经好久没有赶超上来的文章，翻来翻去就这么几篇，对我来说是一种侧面打击，而且无论从用户体验、用户粘度或者 SEO 的角度来说都并不太好，所以今天在“点击最高”和“热评日志”的函数上做了些小小的手脚，加上了时间范围，让这两个版块上显示近一个月内的文章，那样就会有不断的新鲜文章更替上来。</p>
<p>正好，有两种限制时间范围的方法，我就分别介绍一下啦。</p>
<p><strong>方法一：</strong>在 WordPress 主题的相关函数中找到 where 条件句，在其中加上一句条件句：post_date &gt; date_sub( NOW(), INTERVAL 1 MONTH )，这个具体什么意思我就不解释了，还是很好理解的嘛，顺便拿自己的“点击最高”的代码作个例子，仅作参考哟，因为需要插件配合，不是通用的。</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span><br />
<span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">hot_posts</span>(<span style="color: #000000;">$limit</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">10</span><span style="color: #000000;">,</span> <span style="color: #000000;">$cut_off</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000000;">,</span> <span style="color: #000000;">$before</span><span style="color: #000000;">=</span><span style="color: #0000ff;">'&lt;li&gt;'</span><span style="color: #000000;">,</span> <span style="color: #000000;">$after</span><span style="color: #000000;">=</span><span style="color: #0000ff;">'&lt;/li&gt;'</span><span style="color: #000000;">){</span><br />
<span style="color: #000080; font-weight: bold;">global</span> <span style="color: #000000;">$wpdb</span>;<br />
<span style="color: #000000;">$home</span> <span style="color: #000000;">=</span> <span style="color: #000000;">get_option</span>(<span style="color: #0000ff;">'siteurl'</span>);<br />
<span style="color: #000000;">$lastXs</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">get_results</span>(<span style="color: #0000ff;">"SELECT "</span><span style="color: #000000;">.</span><span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">posts</span><span style="color: #000000;">.</span><span style="color: #0000ff;">".ID AS ID,"</span><span style="color: #000000;">.</span><span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">posts</span><span style="color: #000000;">.</span><span style="color: #0000ff;">".post_title AS TITLE ,"</span><span style="color: #000000;">.</span><span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">post_counter</span><span style="color: #000000;">.</span><span style="color: #0000ff;">".post_count AS ZAEHLER FROM "</span><span style="color: #000000;">.</span><span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">posts</span><span style="color: #000000;">.</span><span style="color: #0000ff;">","</span><span style="color: #000000;">.</span><span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">post_counter</span><span style="color: #000000;">.</span><span style="color: #0000ff;">" where "</span><span style="color: #000000;">.</span><span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">post_counter</span><span style="color: #000000;">.</span><span style="color: #0000ff;">".post_id = "</span><span style="color: #000000;">.</span><span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">posts</span><span style="color: #000000;">.</span><span style="color: #0000ff;">".ID AND post_type = 'post' AND post_date &gt; date_sub( NOW(), INTERVAL 1 MONTH ) AND ("</span><span style="color: #000000;">.</span><span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">posts</span><span style="color: #000000;">.</span><span style="color: #0000ff;">".post_status = 'static' OR "</span><span style="color: #000000;">.</span><span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">posts</span><span style="color: #000000;">.</span><span style="color: #0000ff;">".post_status = 'publish') order by "</span><span style="color: #000000;">.</span><span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">post_counter</span><span style="color: #000000;">.</span><span style="color: #0000ff;">".post_count DESC limit 0,"</span><span style="color: #000000;">.</span><span style="color: #000000;">$limit</span>);<br />
<span style="color: #000080; font-weight: bold;">foreach</span> (<span style="color: #000000;">$lastXs</span> <span style="color: #000080; font-weight: bold;">as</span> <span style="color: #000000;">$lastX</span>) <span style="color: #000000;">{</span><br />
<span style="color: #000000;">$nummer</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$lastX</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">ID</span>;<br />
<span style="color: #000000;">$title</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$lastX</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">TITLE</span>;<br />
<span style="color: #000000;">$title</span> <span style="color: #000000;">=</span> <span style="color: #000000;">wptexturize</span>(<span style="color: #000000;">$title</span>);<br />
<span style="color: #000080; font-weight: bold;">if</span> (<span style="color: #000000;">$cut_off</span><span style="color: #000000;">&gt;</span><span style="color: #0000ff;">0</span><span style="color: #000000;">){</span><br />
<span style="color: #000000;">$title_short</span> <span style="color: #000000;">=</span> <span style="color: #000000;">substr</span>(<span style="color: #000000;">$title</span><span style="color: #000000;">,</span><span style="color: #0000ff;">0</span><span style="color: #000000;">,</span><span style="color: #000000;">$cut_off</span>);<br />
<span style="color: #000000;">}</span><span style="color: #000080; font-weight: bold;">else</span><span style="color: #000000;">{</span><br />
<span style="color: #000000;">$title_short</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$title</span>;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">$hotposts</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$lastX</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">ZAEHLER</span>;<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #000000;">$before</span> <span style="color: #000000;">.</span> <span style="color: #0000ff;">"&lt;span class=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">hotposttitle</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">&gt;&lt;a href='"</span><span style="color: #000000;">.</span><span style="color: #000000;">get_permalink</span>(<span style="color: #000000;">$nummer</span>)<span style="color: #000000;">.</span><span style="color: #0000ff;">"' title='"</span><span style="color: #000000;">.</span><span style="color: #000000;">$title</span><span style="color: #000000;">.</span><span style="color: #0000ff;">"'&gt;"</span><span style="color: #000000;">.</span> <span style="color: #000000;">$title_short</span> <span style="color: #000000;">.</span> <span style="color: #0000ff;">"&lt;/a&gt;&lt;/span&gt;&lt;span class=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">hotcomment</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">&gt; ("</span><span style="color: #000000;">.</span><span style="color: #000000;">$hotposts</span><span style="color: #000000;">.</span><span style="color: #0000ff;">" 次点击)&lt;/span&gt;"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$after</span> ;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #008080;">?&gt;</span></div>
<p><strong>方法二：</strong>在 WordPress 主题的相关函数中找到 where 条件句，在其中加上一句条件句：TO_DAYS( now( ) ) - TO_DAYS( post_date ) &lt; 31，这31就是限制的时间范围天数，这里限制了31天内，也就是一个自然月内啦，效果和方法一是一样一样的。用我的“热评日志”的代码作个例子，这个代码可以通用，尽情享用吧～</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span><br />
<span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">mostcommented</span>(<span style="color: #000000;">$limit</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">5</span>) <span style="color: #000000;">{</span><br />
<span style="color: #000080; font-weight: bold;">global</span> <span style="color: #000000;">$wpdb</span><span style="color: #000000;">,</span> <span style="color: #000000;">$post</span><span style="color: #000000;">,</span> <span style="color: #000000;">$tableposts</span><span style="color: #000000;">,</span> <span style="color: #000000;">$tablecomments</span><span style="color: #000000;">,</span> <span style="color: #000000;">$time_difference</span><span style="color: #000000;">,</span> <span style="color: #000000;">$post</span>;<br />
<span style="color: #000000;">$mostcommenteds</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">get_results</span>(<span style="color: #0000ff;">"SELECT  </span><span style="color: #0000ff;">$tableposts</span><span style="color: #0000ff;">.ID as ID, post_title, post_name, COUNT(</span><span style="color: #0000ff;">$tablecomments</span><span style="color: #0000ff;">.comment_post_ID) AS 'comment_total' FROM </span><span style="color: #0000ff;">$tableposts</span><span style="color: #0000ff;"> LEFT JOIN </span><span style="color: #0000ff;">$tablecomments</span><span style="color: #0000ff;"> ON </span><span style="color: #0000ff;">$tableposts</span><span style="color: #0000ff;">.ID = </span><span style="color: #0000ff;">$tablecomments</span><span style="color: #0000ff;">.comment_post_ID WHERE comment_approved = '1' AND TO_DAYS( now( ) ) - TO_DAYS( post_date ) &lt; 31 AND post_status = 'publish' AND post_password = ''  AND post_type = 'post' GROUP BY </span><span style="color: #0000ff;">$tablecomments</span><span style="color: #0000ff;">.comment_post_ID ORDER  BY comment_total DESC LIMIT </span><span style="color: #0000ff;">$limit</span><span style="color: #0000ff;">"</span>);<br />
<span style="color: #000080; font-weight: bold;">foreach</span> (<span style="color: #000000;">$mostcommenteds</span> <span style="color: #000080; font-weight: bold;">as</span> <span style="color: #000000;">$post</span>) <span style="color: #000000;">{</span><br />
<span style="color: #000000;">$post_id</span> <span style="color: #000000;">=</span> (<span style="color: #000000;">int</span>) <span style="color: #000000;">$post</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">post_id</span>;<br />
<span style="color: #000000;">$post_title</span> <span style="color: #000000;">=</span> <span style="color: #000000;">htmlspecialchars</span>(<span style="color: #000000;">stripslashes</span>(<span style="color: #000000;">$post</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">post_title</span>));<br />
<span style="color: #000000;">$comment_total</span> <span style="color: #000000;">=</span> (<span style="color: #000000;">int</span>) <span style="color: #000000;">$post</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">comment_total</span>;<br />
<span style="color: #000000;">$permalink</span> <span style="color: #000000;">=</span> <span style="color: #000000;">get_permalink</span>(<span style="color: #000000;">$post</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">ID</span>);<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #0000ff;">"&lt;li&gt;&lt;span class=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">hotposttitle</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">&gt;&lt;a title='</span><span style="color: #0000ff;">$post_title</span><span style="color: #0000ff;">' href=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">$permalink</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">&gt;</span><span style="color: #0000ff;">$post_title</span><span style="color: #0000ff;">&lt;/a&gt;&lt;/span&gt;&lt;span class=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">hotcomment</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">&gt;(</span><span style="color: #0000ff;">$comment_total</span><span style="color: #0000ff;"> 条评论)&lt;/span&gt;&lt;/li&gt; "</span>;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #008080;">?&gt;</span></div>
<p>效果就见我的侧边栏 TAB 吧，现在显示的都是最近一个月内的点击最高和热评日志。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a>,<a href="http://wange.im/tag/sidebar/" title="侧边栏" rel="tag">侧边栏</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/widgets.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="给 Wordpress 主题添加个性化小工具" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/add-widgets-for-wordpress.html" rel="bookmark" title="给 Wordpress 主题添加个性化小工具">给 Wordpress 主题添加个性化小工具</a>        <div class="rl_date">2011年01月16日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/statistics.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="Wordpress 非插件统计网站访问信息" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wordpress-ip-statistics-without-plugins.html" rel="bookmark" title="Wordpress 非插件统计网站访问信息">Wordpress 非插件统计网站访问信息</a>        <div class="rl_date">2010年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wordpress-statistics-without-plugins.html" rel="bookmark" title="Wordpress 非插件统计网站信息">Wordpress 非插件统计网站信息</a>        <div class="rl_date">2010年03月20日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/mouseover-link-slide-for-wordpress.html" rel="bookmark" title="Wordpress 之链接平移 JQuery 特效">Wordpress 之链接平移 JQuery 特效</a>        <div class="rl_date">2010年02月19日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/display-article-in-a-period-of-time-in-wordpress.html/feed</wfw:commentRss>
		<slash:comments>70</slash:comments>
		</item>
		<item>
		<title>招、招、招广告啦～～～</title>
		<link>http://wange.im/ads-for-sale.html</link>
		<comments>http://wange.im/ads-for-sale.html#comments</comments>
		<pubDate>Tue, 02 Mar 2010 13:11:31 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[三言两语]]></category>
		<category><![CDATA[侧边栏]]></category>
		<category><![CDATA[博客]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[广告]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2786</guid>
		<description><![CDATA[距离上一次招广告已经有3个半月了，那次招广告是为了凑钱看《2012》，感谢歪酷人博客主机的广告赞助，愿望已经实现。这次再招广告要给自己找个什么借口好呢？嗯，对了，前段时间用 JQuery 实现了带滑动层的图片展示效果，看来看去放广告很是不错，就放广告吧，否则空晾着这效果多浪费呀。 在我正式发布此文招广告赞助之前，内页侧边栏的两个广告位已经被迅速占领，看来我的广告位还不是一文不值呀，一狠心又放了两个空位，呀呵，今天又被占领一个。哈哈，这下我来劲了，索性在首页的侧边栏也放上了两个广告位。 一号广告位：（已被煎蛋同学占领） 位置 内页侧边栏 格式与尺寸 165px × 165px 图片 价格 一口价 50大洋/月 支付方式 支付宝 申明 1、非法广告不接 2、瘦身美容广告不接 3、看不顺眼的广告不接 4、预付款 5、图片自备 6、谢绝试用期 7、支持图片标题和描述（描述中仅限单个外链，增加外链需10元/月/个） 8、最终解释权归万戈所有 二号广告位： 位置 首页侧边栏 格式与尺寸 165px × 165px 图片 价格 一口价——100大洋/月 支付方式 支付宝 申明 1、非法广告不接 2、瘦身美容广告不接 3、看不顺眼的广告不接 4、预付款 5、图片自备 6、谢绝试用期 7、支持图片标题和描述（描述中仅限单个外链，增加外链需10元/月/个） 8、最终解释权归万戈所有 三号广告位： 位置 首页侧边栏 格式与尺寸 165px × 165px 图片 [...]]]></description>
			<content:encoded><![CDATA[<p>距离<a title="小站的广告位值多少钱？" href="http://wange.im/how-much-is-my-ads-worth.html">上一次招广告</a>已经有3个半月了，那次招广告是为了凑钱看《2012》，感谢<a href="http://yculer.com/" target="_blank">歪酷人博客主机</a>的广告赞助，愿望已经实现。这次再招广告要给自己找个什么借口好呢？嗯，对了，前段时间用 <a title="JQuery 实现带滑动层的图片展示效果" href="http://wange.im/jquery-slide-pic-show.html">JQuery 实现了带滑动层的图片展示效果</a>，看来看去放广告很是不错，就放广告吧，否则空晾着这效果多浪费呀。</p>
<p>在我正式发布此文招广告赞助之前，内页侧边栏的两个广告位已经被迅速占领，看来我的广告位还不是一文不值呀，一狠心又放了两个空位，呀呵，今天又被占领一个。哈哈，这下我来劲了，索性在首页的侧边栏也放上了两个广告位。</p>
<p><span id="ad1"><span style="text-decoration: line-through;">一号广告位：</span></span>（已被<a title="传说中的，煎蛋" href="http://jandan.net/u/19" target="_blank">煎蛋</a>同学占领）</p>
<table class="table" border="1" width="500" align="center">
<tbody>
<tr>
<td><strong>位置</strong></td>
<td>内页侧边栏</td>
</tr>
<tr>
<td><strong>格式与尺寸</strong></td>
<td>165px × 165px 图片</td>
</tr>
<tr>
<td><strong>价格</strong></td>
<td>一口价 50大洋/月</td>
</tr>
<tr>
<td><strong>支付方式</strong></td>
<td>支付宝</td>
</tr>
<tr>
<td><strong>申明</strong></td>
<td>1、非法广告不接<br />
2、瘦身美容广告不接<br />
3、看不顺眼的广告不接<br />
4、预付款<br />
5、图片自备<br />
6、谢绝试用期<br />
7、支持图片标题和描述（描述中仅限单个外链，增加外链需10元/月/个）<br />
8、最终解释权归万戈所有</td>
</tr>
</tbody>
</table>
<p><span id="ad2">二号广告位：</span></p>
<table class="table" border="1" width="500" align="center">
<tbody>
<tr>
<td><strong>位置</strong></td>
<td>首页侧边栏</td>
</tr>
<tr>
<td><strong>格式与尺寸</strong></td>
<td>165px × 165px 图片</td>
</tr>
<tr>
<td><strong>价格</strong></td>
<td>一口价——100大洋/月</td>
</tr>
<tr>
<td><strong>支付方式</strong></td>
<td>支付宝</td>
</tr>
<tr>
<td><strong>申明</strong></td>
<td>1、非法广告不接<br />
2、瘦身美容广告不接<br />
3、看不顺眼的广告不接<br />
4、预付款<br />
5、图片自备<br />
6、谢绝试用期<br />
7、支持图片标题和描述（描述中仅限单个外链，增加外链需10元/月/个）<br />
8、最终解释权归万戈所有</td>
</tr>
</tbody>
</table>
<p><span id="ad3">三号广告位：</span></p>
<table class="table" border="1" width="500" align="center">
<tbody>
<tr>
<td><strong>位置</strong></td>
<td>首页侧边栏</td>
</tr>
<tr>
<td><strong>格式与尺寸</strong></td>
<td>165px × 165px 图片</td>
</tr>
<tr>
<td><strong>价格</strong></td>
<td>拍卖——起拍价 10大洋/月，每次加价增幅10大洋起</td>
</tr>
<tr>
<td><strong>支付方式</strong></td>
<td>支付宝</td>
</tr>
<tr>
<td><strong>申明</strong></td>
<td>1、非法广告不接<br />
2、瘦身美容广告不接<br />
3、看不顺眼的广告不接<br />
4、预付款<br />
5、图片自备<br />
6、谢绝试用期<br />
7、每人每次限拍一月<br />
8、支持图片标题和描述（描述中仅限单个外链，增加外链需10元/月/个）<br />
9、最终解释权归万戈所有</td>
</tr>
</tbody>
</table>
<p>如果哪位慧眼识广告位，相中了这三块广告位，请Q我：101149488</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/sidebar/" title="侧边栏" rel="tag">侧边栏</a>,<a href="http://wange.im/tag/blog/" title="博客" rel="tag">博客</a>,<a href="http://wange.im/tag/picture/" title="图片" rel="tag">图片</a>,<a href="http://wange.im/tag/ad/" title="广告" rel="tag">广告</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/mood.jpg" alt="三言两语" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-slide-pic-show.html" rel="bookmark" title="JQuery 实现带滑动层的图片展示效果">JQuery 实现带滑动层的图片展示效果</a>        <div class="rl_date">2010年02月24日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/nuffnang.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="拿福能千人挑战有奖活动" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/nuffnang-challenge-1000.html" rel="bookmark" title="拿福能千人挑战有奖活动">拿福能千人挑战有奖活动</a>        <div class="rl_date">2011年05月23日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/img_1304835725_15.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="拿福能博主北京聚会" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/nuffnang-beijing-party.html" rel="bookmark" title="拿福能博主北京聚会">拿福能博主北京聚会</a>        <div class="rl_date">2011年05月8日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/mood.jpg" alt="三言两语" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/blog-advertising-new-models.html" rel="bookmark" title="自创博客广告新模式">自创博客广告新模式</a>        <div class="rl_date">2010年05月9日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/ads-for-sale.html/feed</wfw:commentRss>
		<slash:comments>146</slash:comments>
		</item>
		<item>
		<title>JQuery 实现带滑动层的图片展示效果</title>
		<link>http://wange.im/jquery-slide-pic-show.html</link>
		<comments>http://wange.im/jquery-slide-pic-show.html#comments</comments>
		<pubDate>Wed, 24 Feb 2010 07:15:07 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[侧边栏]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[广告]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2750</guid>
		<description><![CDATA[和我一样用 D&#38;Z theme 的童鞋应该都看到过 zEUS 老大的网站，在其内页的侧边栏里有3列4行匡威的图片广告，当鼠标移动到每一张图片广告上时都会有一个半透明的层滑动上来显示广告的详细信息，很明显，这是一个 JQuery 实现的特效，相当的酷。只是可惜 zEUS 老大没有写出相关的教程，不过很巧的是，我在幸福收藏夹那里找到了答案：利用jQuery制作具有滑动动画效果的层。 先看一下我在本主题上的应用效果吧，请见侧边栏，我把原本单调的一张图片广告加上了滑动层，把鼠标移上去就可以显示文字信息。顺便空出了一个广告位，正在火热招租中，跳楼价40元/月，快来抢啊！！！ 下面是简单的制作过程： 1、HTML 部分 &#60;div class="boxgrid caption"&#62;     &#60;img src="images/ad.gif"/&#62;     &#60;div class="cover boxcaption"&#62;         &#60;h3&#62;标题&#60;/h3&#62;         &#60;p&#62;详细信息&#60;/p&#62;     &#60;/div&#62; &#60;/div&#62; 2、CSS 部分 .boxgrid{     width: 325px;     height: 260px;     margin:10px;     float:left;     background:#161613;     border: solid 2px #8399AF;     overflow: hidden;     position: [...]]]></description>
			<content:encoded><![CDATA[<p>和我一样用 D&amp;Z theme 的童鞋应该都看到过 <a title="zEUS.’Blog" href="http://zeuscn.net" target="_blank">zEUS</a> 老大的网站，在其内页的侧边栏里有3列4行匡威的图片广告，当鼠标移动到每一张图片广告上时都会有一个半透明的层滑动上来显示广告的详细信息，很明显，这是一个 JQuery 实现的特效，相当的酷。只是可惜 zEUS 老大没有写出相关的教程，不过很巧的是，我在<a title="幸福收藏夹" href="http://www.happinesz.cn" target="_blank">幸福收藏夹</a>那里找到了答案：<a title="利用jQuery制作具有滑动动画效果的层" rel="external nofollow" href="http://www.happinesz.cn/archives/1167/" target="_blank">利用jQuery制作具有滑动动画效果的层</a>。</p>
<p>先看一下我在本主题上的应用效果吧，请见侧边栏，我把原本单调的一张图片广告加上了滑动层，把鼠标移上去就可以显示文字信息。<span style="color: #ff0000;">顺便空出了一个广告位，正在火热招租中，跳楼价40元/月，快来抢啊！！！</span></p>
<p>下面是简单的制作过程：</p>
<p><strong>1、HTML 部分</strong></p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"boxgrid caption"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;img</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"images/ad.gif"</span><span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"cover boxcaption"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
        <span style="color: #000080; font-weight: bold;">&lt;h3&gt;</span><span style="color: #000000;">标题</span><span style="color: #000080; font-weight: bold;">&lt;/h3&gt;</span><br />
        <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">详细信息</span><span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span></div>
<p><strong>2、CSS 部分</strong></p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">.boxgrid</span><span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">width</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">325px</span>;<br />
    <span style="color: #000080; font-weight: bold;">height</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">260px</span>;<br />
    <span style="color: #000080; font-weight: bold;">margin</span><span style="color: #000000;">:</span><span style="color: #0000ff;">10px</span>;<br />
    <span style="color: #000080; font-weight: bold;">float</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">left</span>;<br />
    <span style="color: #000080; font-weight: bold;">background</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#161613</span>;<br />
    <span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">:</span> <span style="color: #000080; font-weight: bold;">solid</span> <span style="color: #0000ff;">2px</span> <span style="color: #0000ff;">#8399AF</span>;<br />
    <span style="color: #000080; font-weight: bold;">overflow</span><span style="color: #000000;">:</span> <span style="color: #000080; font-weight: bold;">hidden</span>;<br />
    <span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span> <span style="color: #000080; font-weight: bold;">relative</span>;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">.boxgrid</span> <span style="color: #000080; font-weight: bold;">img</span><span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span> <span style="color: #000080; font-weight: bold;">absolute</span>;<br />
    <span style="color: #000080; font-weight: bold;">top</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">0</span>;<br />
    <span style="color: #000080; font-weight: bold;">left</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">0</span>;<br />
    <span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">0</span>;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">.boxgrid</span> p<span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">padding</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">0</span> <span style="color: #0000ff;">10px</span>;<br />
    <span style="color: #000080; font-weight: bold;">color</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#afafaf</span>;<br />
    <span style="color: #000080; font-weight: bold;">font-weight</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">bold</span>;<br />
    <span style="color: #000080; font-weight: bold;">font</span><span style="color: #000000;">:</span><span style="color: #0000ff;">10pt</span> <span style="color: #0000ff;">"Lucida Grande"</span><span style="color: #000000;">,</span> <span style="color: #000000;">Arial</span><span style="color: #000000;">,</span> <span style="color: #000080; font-weight: bold;">sans-serif</span>;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">.boxcaption</span><span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">float</span><span style="color: #000000;">:</span> <span style="color: #000080; font-weight: bold;">left</span>;<br />
    <span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span> <span style="color: #000080; font-weight: bold;">absolute</span>;<br />
    <span style="color: #000080; font-weight: bold;">background</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">#000</span>;<br />
    <span style="color: #000080; font-weight: bold;">height</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">100px</span>;<br />
    <span style="color: #000080; font-weight: bold;">width</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">100%</span>;<br />
    <span style="color: #000080; font-weight: bold;">opacity</span><span style="color: #000000;">:</span> <span style="color: #000000;">.</span><span style="color: #0000ff;">8</span>;<br />
    <span style="font-style: italic; color: #008800;">/* For IE 5-7 */</span><br />
    <span style="color: #000000;">filter</span><span style="color: #000000;">:</span> <span style="color: #000000;">progid</span><span style="color: #000000;">:</span><span style="color: #000000;">DXImageTransform</span><span style="color: #000000;">.</span><span style="color: #000000;">Microsoft</span><span style="color: #000000;">.</span><span style="color: #000000;">Alpha</span>(<span style="color: #000000;">Opacity</span><span style="color: #000000;">=</span><span style="color: #0000ff;">80</span>);<br />
    <span style="font-style: italic; color: #008800;">/* For IE 8 */</span><br />
    <span style="color: #000000;">-</span><span style="color: #000000;">MS</span><span style="color: #000000;">-</span><span style="color: #000000;">filter</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"</span>;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">.caption</span> <span style="color: #000000;">.boxcaption</span> <span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">top</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">220</span>;<br />
    <span style="color: #000080; font-weight: bold;">left</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">0</span>;<br />
<span style="color: #000000;">}</span></div>
<p><strong>3、载入 JQuery</strong></p>
<p>用 JQuery 1.2 就完全足够了，小巧，推荐。</p>
<p><strong>4、JQuery 执行代码</strong></p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #000000;">document</span><span style="color: #000000;">).</span><span style="color: #000000;">ready</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
        <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'.boxgrid.caption'</span><span style="color: #000000;">).</span><span style="color: #000000;">hover</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
                <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".cover"</span><span style="color: #000000;">,</span> <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">stop</span><span style="color: #000000;">().</span><span style="color: #000000;">animate</span><span style="color: #000000;">({</span><span style="color: #000000;">top</span><span style="color: #000000;">:</span><span style="color: #0000ff;">'160px'</span><span style="color: #000000;">},{</span><span style="color: #000000;">queue</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">false</span><span style="color: #000000;">,</span><span style="color: #000000;">duration</span><span style="color: #000000;">:</span><span style="color: #0000ff;">160</span><span style="color: #000000;">});</span><br />
        <span style="color: #000000;">},</span> <span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
                <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".cover"</span><span style="color: #000000;">,</span> <span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">stop</span><span style="color: #000000;">().</span><span style="color: #000000;">animate</span><span style="color: #000000;">({</span><span style="color: #000000;">top</span><span style="color: #000000;">:</span><span style="color: #0000ff;">'220px'</span><span style="color: #000000;">},{</span><span style="color: #000000;">queue</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">false</span><span style="color: #000000;">,</span><span style="color: #000000;">duration</span><span style="color: #000000;">:</span><span style="color: #0000ff;">160</span><span style="color: #000000;">});</span><br />
        <span style="color: #000000;">});</span><br />
<span style="color: #000000;">});</span></div>
<p>这里我只用了一种滑动效果，所以只需要以上这一段 JS 即可，更多滑动效果预览及参考代码请见：<a href="http://buildinternet.com/live/boxes/" target="blank">预览</a> | <a href="http://buildinternet.com/live/boxes/slidingboxes.zip" target="blank">下载这个实例的源文件</a></p>
<p>我只会拿来主义，把别人的东西加到自己的网站上，所以请别问我为什么，怎么做，想要知道其中原理并扩展发挥的朋友可以见此文：<a title="利用jQuery制作具有滑动动画效果的层" href="http://www.happinesz.cn/archives/1167/" target="_blank">http://www.happinesz.cn/archives/1167/</a></p>
<p>最后，强调一下本文的重点：<span style="color: #ff0000;">我在招广告啊！！！</span>望乡亲父老、萝莉御姐们奔走相告，谢谢。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/sidebar/" title="侧边栏" rel="tag">侧边栏</a>,<a href="http://wange.im/tag/picture/" title="图片" rel="tag">图片</a>,<a href="http://wange.im/tag/ad/" title="广告" rel="tag">广告</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/ads-for-sale.html" rel="bookmark" title="招、招、招广告啦～～～">招、招、招广告啦～～～</a>        <div class="rl_date">2010年03月2日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/marquee-scroll.html" rel="bookmark" title="基于 jQuery 的图片/文字无缝滚动">基于 jQuery 的图片/文字无缝滚动</a>        <div class="rl_date">2011年12月20日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-highslide-on-demand.html" rel="bookmark" title="jQuery 按需加载 HighSlide 效果">jQuery 按需加载 HighSlide 效果</a>        <div class="rl_date">2011年10月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/jquery-slide-pic-show.html/feed</wfw:commentRss>
		<slash:comments>82</slash:comments>
		</item>
		<item>
		<title>WordPress 之链接平移 JQuery 特效</title>
		<link>http://wange.im/mouseover-link-slide-for-wordpress.html</link>
		<comments>http://wange.im/mouseover-link-slide-for-wordpress.html#comments</comments>
		<pubDate>Fri, 19 Feb 2010 12:28:39 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[侧边栏]]></category>
		<category><![CDATA[链接]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2727</guid>
		<description><![CDATA[前段时间给 WordPress 添加了页面载入中提示效果，这是一个 JQuery 的特效，使用前必须先加载一下几十K之巨的 JQuery 库，而我整个 WordPress 也就这么一个地方利用到了 JQuery 库，如果不充分利用起来似乎有些浪费，所以今天又加上了两个。 主要介绍下 mouseover 链接右平移效果。本人表达能力比较差，所以还是直接看效果吧，请见侧边栏。将鼠标移至无序列表的链接上，就会发现文本链接向右移动了一下下，鼠标移开后，又恢复至原位。 方法如下： 1、载入 JQuery 库，个人比较喜欢 JQuery 1.2系列的版本，短小精悍，太大浪费，俺用不到。 2、关键代码： jQuery.fn.nudge = function(a) {a = jQuery.extend({amount: 20,duration: 300,property: "padding",direction: "left",toCallback: function() {},fromCallback: function() {}},a);this.each(function() {var h = jQuery(this);var e = a;var d = e.direction;var g = e.property + d.substring(0, 1).toUpperCase() + d.substring(1, d.length);var c [...]]]></description>
			<content:encoded><![CDATA[<p>前段时间给 WordPress <a title="首页添加页面载入中提示效果" href="http://wange.im/loading-effect-by-jquery.html">添加了页面载入中提示效果</a>，这是一个 JQuery 的特效，使用前必须先加载一下几十K之巨的 JQuery 库，而我整个 WordPress 也就这么一个地方利用到了 JQuery 库，如果不充分利用起来似乎有些浪费，所以今天又加上了两个。</p>
<p>主要介绍下 mouseover 链接右平移效果。本人表达能力比较差，所以还是直接看效果吧，请见侧边栏。将鼠标移至无序列表的链接上，就会发现文本链接向右移动了一下下，鼠标移开后，又恢复至原位。</p>
<p>方法如下：</p>
<p>1、载入 JQuery 库，个人比较喜欢 JQuery 1.2系列的版本，短小精悍，太大浪费，俺用不到。</p>
<p>2、关键代码：</p>
<div class="source" style="color: #000000; font-family: 'Courier New','Lucida Console','monospace';"><span style="color: #000000;">jQuery</span><span style="color: #000000;">.</span><span style="color: #000000;">fn</span><span style="color: #000000;">.</span><span style="color: #000000;">nudge</span> <span style="color: #000000;">=</span> <span style="font-weight: bold; color: #000080;">function</span>(<span style="color: #000000;">a</span>) <span style="color: #000000;">{</span><span style="color: #000000;">a</span> <span style="color: #000000;">=</span> <span style="color: #000000;">jQuery</span><span style="color: #000000;">.</span><span style="color: #000000;">extend</span><span style="color: #000000;">({</span><span style="color: #000000;">amount</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">20</span><span style="color: #000000;">,</span><span style="color: #000000;">duration</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">300</span><span style="color: #000000;">,</span><span style="color: #000000;">property</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">"padding"</span><span style="color: #000000;">,</span><span style="color: #000000;">direction</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">"left"</span><span style="color: #000000;">,</span><span style="color: #000000;">toCallback</span><span style="color: #000000;">:</span> <span style="font-weight: bold; color: #000080;">function</span>() <span style="color: #000000;">{},</span><span style="color: #000000;">fromCallback</span><span style="color: #000000;">:</span> <span style="font-weight: bold; color: #000080;">function</span>() <span style="color: #000000;">{}},</span><span style="color: #000000;">a</span>);<span style="font-weight: bold; color: #000080;">this</span><span style="color: #000000;">.</span><span style="color: #000000;">each</span>(<span style="font-weight: bold; color: #000080;">function</span>() <span style="color: #000000;">{</span><span style="font-weight: bold; color: #000080;">var</span> <span style="color: #000000;">h</span> <span style="color: #000000;">=</span> <span style="color: #000000;">jQuery</span>(<span style="font-weight: bold; color: #000080;">this</span>);<span style="font-weight: bold; color: #000080;">var</span> <span style="color: #000000;">e</span> <span style="color: #000000;">=</span> <span style="color: #000000;">a</span>;<span style="font-weight: bold; color: #000080;">var</span> <span style="color: #000000;">d</span> <span style="color: #000000;">=</span> <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">direction</span>;<span style="font-weight: bold; color: #000080;">var</span> <span style="color: #000000;">g</span> <span style="color: #000000;">=</span> <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">property</span> <span style="color: #000000;">+</span> <span style="color: #000000;">d</span><span style="color: #000000;">.</span><span style="color: #000000;">substring</span>(<span style="color: #0000ff;">0</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">1</span><span style="color: #000000;">).</span><span style="color: #000000;">toUpperCase</span>() <span style="color: #000000;">+</span> <span style="color: #000000;">d</span><span style="color: #000000;">.</span><span style="color: #000000;">substring</span>(<span style="color: #0000ff;">1</span><span style="color: #000000;">,</span> <span style="color: #000000;">d</span><span style="color: #000000;">.</span><span style="color: #000000;">length</span>);<span style="font-weight: bold; color: #000080;">var</span> <span style="color: #000000;">c</span> <span style="color: #000000;">=</span> <span style="color: #000000;">h</span><span style="color: #000000;">.</span><span style="color: #000000;">css</span>(<span style="color: #000000;">g</span>);<span style="font-weight: bold; color: #000080;">var</span> <span style="color: #000000;">f</span> <span style="color: #000000;">=</span> <span style="color: #000000;">{};</span><span style="color: #000000;">f</span><span style="color: #000000;">[</span><span style="color: #000000;">g</span><span style="color: #000000;">]</span> <span style="color: #000000;">=</span> <span style="color: #000000;">parseInt</span>(<span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">amount</span>) <span style="color: #000000;">+</span> <span style="color: #000000;">parseInt</span>(<span style="color: #000000;">c</span>);<span style="font-weight: bold; color: #000080;">var</span> b <span style="color: #000000;">=</span> <span style="color: #000000;">{};</span>b<span style="color: #000000;">[</span><span style="color: #000000;">g</span><span style="color: #000000;">]</span> <span style="color: #000000;">=</span> <span style="color: #000000;">c</span>;<span style="color: #000000;">h</span><span style="color: #000000;">.</span><span style="color: #000000;">hover</span>(<span style="font-weight: bold; color: #000080;">function</span>() <span style="color: #000000;">{</span><span style="color: #000000;">h</span><span style="color: #000000;">.</span><span style="color: #000000;">stop</span><span style="color: #000000;">().</span><span style="color: #000000;">animate</span>(<span style="color: #000000;">f</span><span style="color: #000000;">,</span> <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">duration</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">""</span><span style="color: #000000;">,</span> <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">toCallback</span><span style="color: #000000;">)},</span><span style="font-weight: bold; color: #000080;">function</span>() <span style="color: #000000;">{</span><span style="color: #000000;">h</span><span style="color: #000000;">.</span><span style="color: #000000;">stop</span><span style="color: #000000;">().</span><span style="color: #000000;">animate</span>(b<span style="color: #000000;">,</span> <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">duration</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">""</span><span style="color: #000000;">,</span> <span style="color: #000000;">e</span><span style="color: #000000;">.</span><span style="color: #000000;">fromCallback</span><span style="color: #000000;">)})});</span><span style="font-weight: bold; color: #000080;">return</span> <span style="font-weight: bold; color: #000080;">this</span><span style="color: #000000;">};</span><span style="color: #000000;">jQuery</span>(<span style="color: #0000ff;">".sidebar li a"</span><span style="color: #000000;">).</span><span style="color: #000000;">nudge</span><span style="color: #000000;">({</span><span style="color: #000000;">property</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">"padding"</span><span style="color: #000000;">,</span><span style="color: #000000;">direction</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">"left"</span><span style="color: #000000;">,</span><span style="color: #000000;">amount</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">6</span><span style="color: #000000;">,</span><span style="color: #000000;">duration</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">166</span><span style="color: #000000;">});</span></div>
<p>其中 .sidebar li a 就是控制需要移动的链接，可以看到我这里只要求侧边栏无序列表的链接移动，如果要整站效果，那就直接一个 a 就可以了，如果还需指定添加其他部分，就用半角逗号隔开，如.sidebar li a,h2 a</p>
<p>另外还需要注意的就是加载顺序，JQuery 库是老大，必须放在前面，Over~</p>
<p><strong>2月20日 更新：</strong></p>
<p>感谢 <a title="Hiro's Blog" href="http://www.ihiro.org/" target="_blank">hiro</a> 同学，他又提供了一个代码更加简洁，效果完全相同的方法，第一步还是载入 JQuery 库，第二步是加入以下 JS。</p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #0000ff;">'.sidebar li a'</span><span style="color: #000000;">).</span><span style="color: #000000;">hover</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
<span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">stop</span><span style="color: #000000;">().</span><span style="color: #000000;">animate</span><span style="color: #000000;">({</span><span style="color: #0000ff;">'left'</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">'5px'</span><span style="color: #000000;">},</span> <span style="color: #0000ff;">'fast'</span>);<br />
<span style="color: #000000;">},</span> <span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
<span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">stop</span><span style="color: #000000;">().</span><span style="color: #000000;">animate</span><span style="color: #000000;">({</span><span style="color: #0000ff;">'left'</span><span style="color: #000000;">:</span> <span style="color: #0000ff;">'0px'</span><span style="color: #000000;">},</span> <span style="color: #0000ff;">'fast'</span>);<br />
<span style="color: #000000;">});</span></div>
<p>第三步，加入以下 CSS：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Lucida Console', 'monospace'; COLOR: #000000" class=source jQuery1266671153281="14"><SPAN style="COLOR: #000000">.sidebar</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">li</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">a</SPAN> <SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">position</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">relative</SPAN><SPAN style="COLOR: #000000">;}</SPAN><BR></DIV></p>
<p>效果相同，代码当然是越短越好啦，不错不错～</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a>,<a href="http://wange.im/tag/sidebar/" title="侧边栏" rel="tag">侧边栏</a>,<a href="http://wange.im/tag/link/" title="链接" rel="tag">链接</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/improve-favicon-in-wordpress-link-with-jquery.html" rel="bookmark" title="JQ 完善 Wordpress 友链的 Favicon">JQ 完善 Wordpress 友链的 Favicon</a>        <div class="rl_date">2010年02月21日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/diy-wordpress-sidebar.html" rel="bookmark" title="个性化 Wordpress 侧边栏">个性化 Wordpress 侧边栏</a>        <div class="rl_date">2009年06月27日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-drag.html" rel="bookmark" title="jQuery 水平拖动效果">jQuery 水平拖动效果</a>        <div class="rl_date">2011年03月4日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wp-postviews-optimization-in-wordpress.html" rel="bookmark" title="Wordpress 速度优化之 WP-PostViews 插件">Wordpress 速度优化之 WP-PostViews 插件</a>        <div class="rl_date">2011年02月9日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/mouseover-link-slide-for-wordpress.html/feed</wfw:commentRss>
		<slash:comments>128</slash:comments>
		</item>
		<item>
		<title>WordPress 侧边栏带头像的最新评论</title>
		<link>http://wange.im/recent-comment-with-avatar-in-wordpress.html</link>
		<comments>http://wange.im/recent-comment-with-avatar-in-wordpress.html#comments</comments>
		<pubDate>Sat, 26 Dec 2009 09:41:00 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[gravatar]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[侧边栏]]></category>
		<category><![CDATA[留言]]></category>
		<category><![CDATA[缓存]]></category>

		<guid isPermaLink="false">http://wange.im/?p=2406</guid>
		<description><![CDATA[谨以本文献给 Nox 童鞋。昨天 Nox 就问我怎么实现 WordPress 带头像的最新评论？因为当时正好在上班，电脑上没有 DW 和 notepad++ 这类软件，玩代码很不爽，又没有实力用 Windows 自带的记事本当场写出，所以就推荐了 zww 的成果：《带头像显示的最新评论代码 - 完善篇》，不过好像还是没有解决 Nox 的问题。现在也只有周末可以折腾折腾 WordPress 了，所以今天就拿自己的 WordPress 开刀，在侧边栏实现了带 gravatar 头像的最新评论。 先说说通用版： &#60;?php global $wpdb; $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,25) AS com_excerpt FROM $wpdb-&#62;comments LEFT OUTER JOIN $wpdb-&#62;posts ON ($wpdb-&#62;comments.comment_post_ID = $wpdb-&#62;posts.ID) [...]]]></description>
			<content:encoded><![CDATA[<p>谨以本文献给 <a title="Nox的记忆匣子" href="http://imn.im/" target="_blank">Nox 童鞋</a>。昨天 Nox 就问我怎么实现 WordPress 带头像的最新评论？因为当时正好在上班，电脑上没有 DW 和 notepad++ 这类软件，玩代码很不爽，又没有实力用 Windows 自带的记事本当场写出，所以就推荐了 zww 的成果：<a title="带头像显示的最新评论代码 - 完善篇" href="http://zww.me/archives/24736" target="_blank">《带头像显示的最新评论代码 - 完善篇》</a>，不过好像还是没有解决 Nox 的问题。现在也只有周末可以折腾折腾 WordPress 了，所以今天就拿自己的 WordPress 开刀，在侧边栏实现了带 gravatar 头像的最新评论。</p>
<p>先说说通用版：</p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span><br />
<span style="color: #000080; font-weight: bold;">global</span> <span style="color: #000000;">$wpdb</span>;<br />
<span style="color: #000000;">$sql</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">"SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,25) AS com_excerpt FROM </span><span style="color: #0000ff;">$wpdb-&gt;comments</span><span style="color: #0000ff;"> LEFT OUTER JOIN </span><span style="color: #0000ff;">$wpdb-&gt;posts</span><span style="color: #0000ff;"> ON (</span><span style="color: #0000ff;">$wpdb-&gt;comments</span><span style="color: #0000ff;">.comment_post_ID = </span><span style="color: #0000ff;">$wpdb-&gt;posts</span><span style="color: #0000ff;">.ID) WHERE comment_approved = '1' AND comment_type = '' AND comment_author != '万戈' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 10"</span>;<br />
<span style="color: #000000;">$comments</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">get_results</span>(<span style="color: #000000;">$sql</span>);<br />
<span style="color: #000000;">$output</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$pre_HTML</span>;<br />
<span style="color: #000080; font-weight: bold;">foreach</span> (<span style="color: #000000;">$comments</span> <span style="color: #000080; font-weight: bold;">as</span> <span style="color: #000000;">$comment</span>) <span style="color: #000000;">{</span><br />
<span style="color: #000000;">$output</span> <span style="color: #000000;">.=</span> <span style="color: #0000ff;">"</span><span style="color: #0000ff;">\n</span><span style="color: #0000ff;">&lt;li&gt;"</span><span style="color: #000000;">.</span><span style="color: #000000;">get_avatar</span>(<span style="color: #000000;">get_comment_author_email</span>(<span style="color: #0000ff;">'comment_author_email'</span><span style="color: #000000;">),</span> <span style="color: #0000ff;">18</span>)<span style="color: #000000;">.</span> <span style="color: #0000ff;">" &lt;a href=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">get_permalink</span>(<span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">ID</span>) <span style="color: #000000;">.</span> <span style="color: #0000ff;">"#comment-"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">comment_ID</span> <span style="color: #000000;">.</span> <span style="color: #0000ff;">"</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;"> title=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">post_title</span> <span style="color: #000000;">.</span> <span style="color: #0000ff;">" 上的评论</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">&gt;"</span><span style="color: #000000;">.</span> <span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">comment_author</span>) <span style="color: #000000;">.</span><span style="color: #0000ff;">"： "</span><span style="color: #000000;">.</span> <span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">com_excerpt</span>) <span style="color: #000000;">.</span><span style="color: #0000ff;">"&lt;/a&gt;&lt;/li&gt;"</span>;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">$output</span> <span style="color: #000000;">.=</span> <span style="color: #000000;">$post_HTML</span>;<br />
<span style="color: #000000;">$output</span> <span style="color: #000000;">=</span> <span style="color: #000000;">convert_smilies</span>(<span style="color: #000000;">$output</span>);<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #000000;">$output</span>;<br />
<span style="color: #008080;">?&gt;</span></div>
<p>再说说 gravatar 头像缓存版的，大家各取所需啦：</p>
<div class="source" style="font-family: 'Courier New','Lucida Console','monospace'; color: #000000;"><span style="color: #008080;">&lt;?php</span><br />
<span style="color: #000080; font-weight: bold;">global</span> <span style="color: #000000;">$wpdb</span>;<br />
<span style="color: #000000;">$sql</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">"SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,25) AS com_excerpt FROM </span><span style="color: #0000ff;">$wpdb-&gt;comments</span><span style="color: #0000ff;"> LEFT OUTER JOIN </span><span style="color: #0000ff;">$wpdb-&gt;posts</span><span style="color: #0000ff;"> ON (</span><span style="color: #0000ff;">$wpdb-&gt;comments</span><span style="color: #0000ff;">.comment_post_ID = </span><span style="color: #0000ff;">$wpdb-&gt;posts</span><span style="color: #0000ff;">.ID) WHERE comment_approved = '1' AND comment_type = '' AND comment_author != '万戈' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 10"</span>;<br />
<span style="color: #000000;">$comments</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$wpdb</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">get_results</span>(<span style="color: #000000;">$sql</span>);<br />
<span style="color: #000000;">$output</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$pre_HTML</span>;<br />
<span style="color: #000080; font-weight: bold;">foreach</span> (<span style="color: #000000;">$comments</span> <span style="color: #000080; font-weight: bold;">as</span> <span style="color: #000000;">$comment</span>) <span style="color: #000000;">{</span><br />
<span style="color: #000000;">$output</span> <span style="color: #000000;">.=</span> <span style="color: #0000ff;">"</span><span style="color: #0000ff;">\n</span><span style="color: #0000ff;">&lt;li&gt;&lt;img width=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">18</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;"> height=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">18</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;"> src=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">http://wange.im/gravatar/cache/avatar/"</span><span style="color: #000000;">.</span><span style="color: #000000;">md5</span>(<span style="color: #000000;">strtolower</span>(<span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">comment_author_email</span>))<span style="color: #000000;">.</span> <span style="color: #0000ff;">" </span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;"> /&gt;&lt;a href=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">get_permalink</span>(<span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">ID</span>) <span style="color: #000000;">.</span> <span style="color: #0000ff;">"#comment-"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">comment_ID</span> <span style="color: #000000;">.</span> <span style="color: #0000ff;">"</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;"> title=</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">"</span> <span style="color: #000000;">.</span> <span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">post_title</span> <span style="color: #000000;">.</span> <span style="color: #0000ff;">" 上的评论</span><span style="color: #0000ff;">\"</span><span style="color: #0000ff;">&gt;"</span><span style="color: #000000;">.</span> <span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">comment_author</span>) <span style="color: #000000;">.</span><span style="color: #0000ff;">"： "</span><span style="color: #000000;">.</span> <span style="color: #000000;">strip_tags</span>(<span style="color: #000000;">$comment</span><span style="color: #000000;">-&gt;</span><span style="color: #ff0000;">com_excerpt</span>) <span style="color: #000000;">.</span><span style="color: #0000ff;">"&lt;/a&gt;&lt;/li&gt;"</span>;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">$output</span> <span style="color: #000000;">.=</span> <span style="color: #000000;">$post_HTML</span>;<br />
<span style="color: #000000;">$output</span> <span style="color: #000000;">=</span> <span style="color: #000000;">convert_smilies</span>(<span style="color: #000000;">$output</span>);<br />
<span style="color: #000080; font-weight: bold;">echo</span> <span style="color: #000000;">$output</span>;<br />
<span style="color: #008080;">?&gt;</span></div>
<p>说明一下：代码中的“万戈”换成各自的名字就行，只是为了<a href="http://wange.im/hide-recent-author-comment-in-wordpress.html">隐藏博主的最新留言</a>，还有 <a title="Wordpress 2.7+主题 gravatar 头像缓存" href="http://wange.im/cache-gravatar-for-wordpress-2-7.html">gravatar 头像缓存</a>的路径就根据各自的实际情况啦。</p>
<p>在完善 WordPress 带头像的最新评论的时候，最折腾我的就是样式，让我够累的，照顾了 Firefox，又忽略了 IE，特别是难缠的 IE6，我也是无能为力了，就先这么着吧，有时间再修改。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/gravatar/" title="gravatar" rel="tag">gravatar</a>,<a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a>,<a href="http://wange.im/tag/sidebar/" title="侧边栏" rel="tag">侧边栏</a>,<a href="http://wange.im/tag/leave-word/" title="留言" rel="tag">留言</a>,<a href="http://wange.im/tag/cache/" title="缓存" rel="tag">缓存</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/commenter-avatar.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="Wordpress 记录评论者 gravatar 头像" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/commenter-gravatar-in-wordpress.html" rel="bookmark" title="Wordpress 记录评论者 gravatar 头像">Wordpress 记录评论者 gravatar 头像</a>        <div class="rl_date">2010年05月18日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/qq-gravatar-cache.html" rel="bookmark" title="QQ 自定义头像+Gravatar 头像缓存">QQ 自定义头像+Gravatar 头像缓存</a>        <div class="rl_date">2010年04月6日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/gravatar-buffer-supplement-in-wordpress.html" rel="bookmark" title="Wordpress gravatar 头像缓存补充说明">Wordpress gravatar 头像缓存补充说明</a>        <div class="rl_date">2010年01月19日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/recent-comments-in-wordpress.html" rel="bookmark" title="求解 Wordpress 最新评论无法定位问题">求解 Wordpress 最新评论无法定位问题</a>        <div class="rl_date">2009年12月14日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/recent-comment-with-avatar-in-wordpress.html/feed</wfw:commentRss>
		<slash:comments>137</slash:comments>
		</item>
	</channel>
</rss>

