<?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>Amio&#039;s Dreamscape &#187; 历史上的今天</title>
	<atom:link href="http://www.amio.cn/blog/tags/%e5%8e%86%e5%8f%b2%e4%b8%8a%e7%9a%84%e4%bb%8a%e5%a4%a9/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.amio.cn/blog</link>
	<description>A whole new world.</description>
	<lastBuildDate>Sun, 04 Jul 2010 05:09:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>WP Hack: Today In History</title>
		<link>http://www.amio.cn/blog/2009/12/wp-hack-today-in-history/</link>
		<comments>http://www.amio.cn/blog/2009/12/wp-hack-today-in-history/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 12:12:06 +0000</pubDate>
		<dc:creator>amio</dc:creator>
				<category><![CDATA[EE & WP Works]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[TodayInHistory]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[历史上的今天]]></category>

		<guid isPermaLink="false">http://www.amio.cn/blog/?p=509</guid>
		<description><![CDATA[<p>　　这是bulaoge上一个挺有意思的功能，能自动在你发的帖子末尾加上以前你曾经在这个日期发布过的主题链接，去年的，前年的——多年以前的12月21日这一天我写了什么？</p>
<p>　　在WP的插件库里找了很长时间，有个1 Year Ago，能在侧栏显示一年前的帖子，但是它的时间基准是当前时间；还有个“Around this date in the past&#8230;”算是“1 Year Ago”的增强版，可以显示任意时间段的帖子，但问题同上，仍然不能基于某篇帖子显示那个日期不同年份的发布内容。最后只好考虑自己做个了。&#160;<a href='http://www.amio.cn/blog/2009/12/wp-hack-today-in-history/' class="more">&#183;&#183;&#183;&#183;&#183;&#183;</a></p>]]></description>
			<content:encoded><![CDATA[<p>　　这是bulaoge上一个挺有意思的功能，能自动在你发的帖子末尾加上以前你曾经在这个日期发布过的主题链接，去年的，前年的——多年以前的12月21日这一天我写了什么？</p>
<p>　　在WP的插件库里找了很长时间，有个1 Year Ago，能在侧栏显示一年前的帖子，但是它的时间基准是当前时间；还有个“Around this date in the past&#8230;”算是“1 Year Ago”的增强版，可以显示任意时间段的帖子，但问题同上，仍然不能基于某篇帖子显示那个日期不同年份的发布内容。最后只好考虑自己做个了。<span id="more-509"></span></p>
<p>　　好在查了文档之后发现还不是太难，代码量很小，不过WP上面写个内容真是不容易，编辑器里满是php标签和html标签混插，可读性极差。这点比EE差远了。</p>
<p>　　OK，来看代码，加在单篇文章的末尾即可：<br />
<pre>&lt;!-- amio: today in history [tih] --&gt;
&lt;?php
$tih_date = split(&#039;-&#039;,the_date(&#039;n-j&#039;,&#039;&#039;,&#039;&#039;,false));
$tih_args = array(
  &#039;monthnum&#039; =&gt; $tih_date[0],
  &#039;day&#039; =&gt; $tih_date[1],
  &#039;order&#039; =&gt; &#039;DEC&#039;,
  &#039;orderby&#039; =&gt; &#039;date&#039;,
  &#039;exclude&#039; =&gt; $post-&gt;ID
  ); 
$postslist = get_posts($tih_args);
if($postslist):
?&gt;
&lt;div id=&quot;tih&quot;&gt;
&lt;span class=&quot;tih-header&quot;&gt;历史上的今天 | Today In History&lt;/span&gt;
&lt;?php foreach ($postslist as $post) : ?&gt;
&lt;div class=&quot;tih-item&quot;&gt;
  &lt;span class=&quot;tih-pdate&quot;&gt;&lt;?php the_time(&#039;M j, Y&#039;); ?&gt;&amp;nbsp;-&amp;nbsp;&lt;/span&gt;
  &lt;a class=&quot;tih-plink&quot; href=&quot;&lt;?php the_permalink(); ?&gt;&quot; id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;?php endforeach; ?&gt;
&lt;/div&gt;
&lt;?php endif; wp_reset_query(); ?&gt;
&lt;!-- amio: today in history [tih] : over --&gt;
</pre></p>
<p>　　剩下的就简单了，样式搞下即可。这是我的，请随意修改怎么好看怎么来：<br />
<pre>
#tih .tih-header { font-size: 12px; font-weight: bold; color: #000; display: block; padding: 4px 0; width: 300px }
#tih .tih-item { padding: 2px 50px }
#tih .tih-pdate { color: #999 }
#tih a.tih-plink { text-decoration: none; color: #222 }
#tih a.tih-plink:hover { color: #000 }
</pre></p>
<p>　　Live Demo：见本文末的“<a href="#tih">历史上的今天 | Today In History</a>”。</p>
<p>　　BTW：<br />
　　WP的自动HTML格式化也不好用啊原来(⊙v⊙)…编辑器样子不错就是。也不能自定义，最大的问题是解析不能自动略过<code>&lt;code&gt;</code>中的内容，除非你手动把代码里的“<”全都修改为字符实体。幸好WP插件多，找了个 Preserve Code Formatting Settings，这下才舒服了。</p>
<p>　　<strong datetime="2010-01-10T15:20:31+00:00">Update 1</strong> (2010-01-10)：<br />
　　发现点Bug，对于某些帖子会导致当页的评论显示为另一篇帖子的评论，最近事儿多，稍后会查这个bug，暂时请勿使用本贴代码。</p>
<p>　　<strong datetime="2010-01-18T16:09:49+00:00">Update 2</strong> (2010-01-18)：<br />
　　问题解决，代码已更新。<br />
　　Thanks to Miu for a relaxing talk.</p>
<p><hr />
<small>博客换了后台，订阅地址改为 <a href="http://www.amio.cn/blog/feed/">http://www.amio.cn/blog/feed/</a>，请更新下订阅地址，多谢。</small></p>]]></content:encoded>
			<wfw:commentRss>http://www.amio.cn/blog/2009/12/wp-hack-today-in-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
