<?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>mitcho.com &#187; plugin</title>
	<atom:link href="http://mitcho.com/blog/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://mitcho.com</link>
	<description></description>
	<lastBuildDate>Fri, 10 Feb 2012 23:24:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19719</generator>
		<item>
		<title>Every website has a purpose</title>
		<link>http://mitcho.com/blog/projects/every-website-has-a-purpose/</link>
		<comments>http://mitcho.com/blog/projects/every-website-has-a-purpose/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 02:16:13 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[projects]]></category>
		<category><![CDATA[A/B testing]]></category>
		<category><![CDATA[Automattic]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[ShrimpTest]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mitcho.com/?p=3714</guid>
		<description><![CDATA[Every website has a purpose. Maybe you want people to buy a product, donate to your cause, download your app, or subscribe to your mailing list. How can you confidently modify your site to make it more effective with respect to this goal? A/B testing is a process by which multiple variants of a website [...]
Related posts:<ol>
<li><a href='http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/' rel='bookmark' title='Markdown for WordPress and bbPress'>Markdown for WordPress and bbPress</a></li>
<li><a href='http://mitcho.com/blog/projects/after-the-deadline-for-firefox/' rel='bookmark' title='After the Deadline for Firefox'>After the Deadline for Firefox</a></li>
<li><a href='http://mitcho.com/blog/projects/extending-wordpress-talk-at-the-boston-wordpress-meetup/' rel='bookmark' title='Extending WordPress talk at the Boston WordPress Meetup'>Extending WordPress talk at the Boston WordPress Meetup</a></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Every website has a purpose. Maybe you want people to buy a product, donate to your cause, download your app, or subscribe to your mailing list. How can you confidently modify your site to make it more effective with respect to this goal?</p>

<p><strong>A/B testing</strong> is a process by which multiple variants of a website are presented to different users randomly and statistical tools are used to see whether any variant is more <em>effective</em>, according to an overall goal metric such as conversions or revenue.</p>

<p>While various A/B testing products—many free—exist, none are made from the ground up to work within the WordPress ecosystem. I believe a solution made particularly for WordPress could make A/B testing so much easier and more straightforward, and that such a solution could be greatly beneficial to the platform as a whole.</p>

<p>I&#8217;m happy to announce my new project, code-named <strong>ShrimpTest</strong>,<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> which is directly aimed at filling this void. I&#8217;ll be working on this project this summer together with the fantastic folks at <a href="http://automattic.com">Automattic</a>.</p>

<p>The best way to keep up with development is on the project&#8217;s development blog, <a href="http://shrimptest.wordpress.com/">the ShrimpTest P2</a>. Most updates will most likely be much shorter than this initial post. <img src='http://mitcho.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  You can get less frequent, milestone-like updates by <a href="http://twitter.com/shrimptest">following ShrimpTest on twitter</a>. Development will be <a href="http://plugins.svn.wordpress.org/shrimptest/">open</a> so feel free to check it out (haha) and submit patches as well. As I go along, I&#8217;ll also look forward to your feedback.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>Five dollars to the first person to correctly guess why I&#8217;m calling it ShrimpTest.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<p>Related posts:</p><ol>
<li><a href='http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/' rel='bookmark' title='Markdown for WordPress and bbPress'>Markdown for WordPress and bbPress</a></li>
<li><a href='http://mitcho.com/blog/projects/after-the-deadline-for-firefox/' rel='bookmark' title='After the Deadline for Firefox'>After the Deadline for Firefox</a></li>
<li><a href='http://mitcho.com/blog/projects/extending-wordpress-talk-at-the-boston-wordpress-meetup/' rel='bookmark' title='Extending WordPress talk at the Boston WordPress Meetup'>Extending WordPress talk at the Boston WordPress Meetup</a></li>
</ol>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/projects/every-website-has-a-purpose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HookPress: Webhooks for WordPress</title>
		<link>http://mitcho.com/blog/projects/hookpress-webhooks-for-wordpress/</link>
		<comments>http://mitcho.com/blog/projects/hookpress-webhooks-for-wordpress/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 02:23:25 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[projects]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[mashups]]></category>
		<category><![CDATA[Mozilla Planet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[webhooks]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Planet]]></category>

		<guid isPermaLink="false">http://mitcho.com/blog/?p=2672</guid>
		<description><![CDATA[I recently have spent a little time putting together a new WordPress plugin called HookPress. HookPress lets you add webhooks to WordPress, letting you easily develop push notifications or extend WordPress in languages other than PHP. WordPress itself is built on a powerful plugin API which provides actions and filters. Actions correspond to events, so [...]
Related posts:<ol>
<li><a href='http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/' rel='bookmark' title='Markdown for WordPress and bbPress'>Markdown for WordPress and bbPress</a></li>
<li><a href='http://mitcho.com/blog/projects/modifiying-wordpress-plugin-activation-behavior/' rel='bookmark' title='Modifiying WordPress plugin activation behavior'>Modifiying WordPress plugin activation behavior</a></li>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/' rel='bookmark' title='Yet Another Related Posts Plugin 2.0'>Yet Another Related Posts Plugin 2.0</a></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I recently have spent a little time putting together a new WordPress plugin called HookPress. <a href="http://wordpress.org/extend/plugins/hookpress/">HookPress</a> lets you add <a href="http://webhooks.org">webhooks</a> to WordPress, letting you easily develop push notifications or extend WordPress in languages other than PHP.</p>

<p>WordPress itself is built on a <a href="http://codex.wordpress.org/Plugin_API">powerful plugin API</a> which provides <a href="http://codex.wordpress.org/Plugin_API/Action_Reference"><strong>actions</strong></a> and <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference"><strong>filters</strong></a>. Actions correspond to events, so you can set a webhook to fire when a post is published or a comment is made.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> Filters let you modify some text when it is saved or displayed, so you can have your external webhook script reformat some text or insert some other content dynamically. Not all actions and filters are supported at this time, but I will continue to add more in.</p>

<p>There&#8217;s a <a href="http://upcoming.yahoo.com/event/4049111">webhooks meetup in San Francisco</a> today but I unfortunately left SF this morning, so I created a video which will be played there as a lightning talk. A demo of both types of webhooks are in the video as well.</p>

<p><object width="649" height="365"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5905102&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5905102&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="649" height="365"></embed></object></p>

<p><a href="http://vimeo.com/5905102">HookPress: add webhooks to WordPress</a> from <a href="http://vimeo.com/mitchoyoshitaka">mitcho</a> on <a href="http://vimeo.com">Vimeo</a>.</p>

<p>I&#8217;m really excited by this very simple but potentially high-impact plugin. I&#8217;d love to get your comments and feedback on this new plugin and hope to hear how you&#8217;re using HookPress!</p>

<p>ADDENDUM: Please also <a href="http://twitter.com/hookpress/">follow HookPress on twitter</a>!</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>My friend Abi actually has already blogged about <a href="http://blog.abi.sh/2009/tweeting-your-blog-with-hookpress/">HookPress and how it can be used to tweet on post publication</a>.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<p>Related posts:</p><ol>
<li><a href='http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/' rel='bookmark' title='Markdown for WordPress and bbPress'>Markdown for WordPress and bbPress</a></li>
<li><a href='http://mitcho.com/blog/projects/modifiying-wordpress-plugin-activation-behavior/' rel='bookmark' title='Modifiying WordPress plugin activation behavior'>Modifiying WordPress plugin activation behavior</a></li>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/' rel='bookmark' title='Yet Another Related Posts Plugin 2.0'>Yet Another Related Posts Plugin 2.0</a></li>
</ol>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/projects/hookpress-webhooks-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Matt Mullenweg recommends YARPP on Tekzilla!</title>
		<link>http://mitcho.com/blog/link/matt-mullenweg-recommends-yarpp-on-tekzilla/</link>
		<comments>http://mitcho.com/blog/link/matt-mullenweg-recommends-yarpp-on-tekzilla/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 08:13:13 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[link]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[Tekzilla]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Planet]]></category>
		<category><![CDATA[YARPP]]></category>

		<guid isPermaLink="false">http://mitcho.com/blog/?p=2240</guid>
		<description><![CDATA[A new user of my WordPress plugin tipped me off to a recent Tekzilla segment where WordPress founder Matt Mullenweg recommended Yet Another Related Posts Plugin as one of his personal favorite WordPress plugins. Thanks Matt! ^^ Related posts: Yet Another Related Posts Plugin 2.0 Using Templates with YARPP 3 Keep up with Yet Another [...]
Related posts:<ol>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/' rel='bookmark' title='Yet Another Related Posts Plugin 2.0'>Yet Another Related Posts Plugin 2.0</a></li>
<li><a href='http://mitcho.com/blog/projects/yarpp-3-templates/' rel='bookmark' title='Using Templates with YARPP 3'>Using Templates with YARPP 3</a></li>
<li><a href='http://mitcho.com/blog/projects/keep-up-with-yet-another-related-posts-plugin-with-rss/' rel='bookmark' title='Keep up with Yet Another Related Posts Plugin with RSS!'>Keep up with Yet Another Related Posts Plugin with RSS!</a></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p><embed class="rev3PlayerEmbed" type="application/x-shockwave-flash" src="http://revision3.com/player-v2887" allowFullScreen="true" allowScriptAccess="always" width="650" height="365" flashvars="startTime=1114&#038;endTime=1166" /></p>

<p>A new user of my <a href="http://wordpress.org">WordPress</a> plugin tipped me off to a recent <a href="http://revision3.com/tekzilla">Tekzilla</a> segment where WordPress founder <a href="http://en.wikipedia.org/wiki/Matt Mullenweg">Matt Mullenweg</a> recommended <a href="/code/yarpp">Yet Another Related Posts Plugin</a> as one of his personal favorite WordPress plugins. Thanks Matt! ^^</p>
<p>Related posts:</p><ol>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/' rel='bookmark' title='Yet Another Related Posts Plugin 2.0'>Yet Another Related Posts Plugin 2.0</a></li>
<li><a href='http://mitcho.com/blog/projects/yarpp-3-templates/' rel='bookmark' title='Using Templates with YARPP 3'>Using Templates with YARPP 3</a></li>
<li><a href='http://mitcho.com/blog/projects/keep-up-with-yet-another-related-posts-plugin-with-rss/' rel='bookmark' title='Keep up with Yet Another Related Posts Plugin with RSS!'>Keep up with Yet Another Related Posts Plugin with RSS!</a></li>
</ol>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/link/matt-mullenweg-recommends-yarpp-on-tekzilla/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Count command for Ubiquity</title>
		<link>http://mitcho.com/blog/projects/count-command-for-ubiquity/</link>
		<comments>http://mitcho.com/blog/projects/count-command-for-ubiquity/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 04:18:26 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[projects]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Mozilla Planet]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[ubiquity]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mitcho.com/blog/?p=1788</guid>
		<description><![CDATA[(This is primarily a blog post to test out Sandro&#8217;s plugin for embedding Ubiquity commands in WordPress. If you don&#8217;t see the &#8220;subscribe to command&#8221; come up, make sure you&#8217;re looking at the single page view.) A while back I created a count command for Ubiquity to count HTML elements on a page, so I&#8217;ll [...]
Related posts:<ol>
<li><a href='http://mitcho.com/blog/projects/friendlier-command-feed-subscription/' rel='bookmark' title='Friendlier command feed subscription'>Friendlier command feed subscription</a></li>
<li><a href='http://mitcho.com/blog/projects/selecting-from-ubiquity/' rel='bookmark' title='selecting from Ubiquity'>selecting from Ubiquity</a></li>
<li><a href='http://mitcho.com/blog/projects/rolling-out-the-roles/' rel='bookmark' title='Rolling out the Roles'>Rolling out the Roles</a></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>(This is primarily a blog post to test out <a href="http://github.com/gialloporpora/wordpress-ubiquity-plugin/tree/master">Sandro&#8217;s plugin for embedding Ubiquity commands in WordPress</a>. If you don&#8217;t see the &#8220;subscribe to command&#8221; come up, make sure you&#8217;re looking at the <a href="http://mitcho.com/blog/projects/count-command-for-ubiquity/">single page view</a>.)</p>

<p>A while back I created a <code>count</code> command for Ubiquity to count HTML elements on a page, so I&#8217;ll share it here. The idea is super simple: select some text on your page and execute <code>count p</code> to get the number of paragraphs, or <code>count a</code> to get the number of links, or <code>count tr</code> to get the number of table rows. This is super useful when reading articles with charts or lists online and you want to know how many there are without doing something like copy-pasting into Excel.</p>

<p>The <code>count</code> command is built using jQuery so it can even understand targets like <code>p.class</code> or <code>a[href=...]</code>. Give it a try! ^^</p>
<p>Related posts:</p><ol>
<li><a href='http://mitcho.com/blog/projects/friendlier-command-feed-subscription/' rel='bookmark' title='Friendlier command feed subscription'>Friendlier command feed subscription</a></li>
<li><a href='http://mitcho.com/blog/projects/selecting-from-ubiquity/' rel='bookmark' title='selecting from Ubiquity'>selecting from Ubiquity</a></li>
<li><a href='http://mitcho.com/blog/projects/rolling-out-the-roles/' rel='bookmark' title='Rolling out the Roles'>Rolling out the Roles</a></li>
</ol>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/projects/count-command-for-ubiquity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>External orders in WordPress queries</title>
		<link>http://mitcho.com/blog/how-to/external-orders-in-wordpress-queries/</link>
		<comments>http://mitcho.com/blog/how-to/external-orders-in-wordpress-queries/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 15:34:40 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[how to]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[query_posts]]></category>
		<category><![CDATA[ranking]]></category>
		<category><![CDATA[suggestions]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Planet]]></category>
		<category><![CDATA[WP_Query]]></category>
		<category><![CDATA[YARPP]]></category>

		<guid isPermaLink="false">http://mitcho.com/blog/?p=1102</guid>
		<description><![CDATA[The advanced WordPress user is intimately familiar with query_posts, the function which controls which posts are displayed in &#8220;The Loop.&#8221; query_posts gives plugin and theme writers the ability to display only posts written in Janary (query_posts("monthnum=1")) or disallow posts from a certain category (query_posts("cat=-529")1). One of the parameters you can set here is orderby which [...]
Related posts:<ol>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/' rel='bookmark' title='Yet Another Related Posts Plugin 2.0'>Yet Another Related Posts Plugin 2.0</a></li>
<li><a href='http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/' rel='bookmark' title='Markdown for WordPress and bbPress'>Markdown for WordPress and bbPress</a></li>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin/' rel='bookmark' title='Yet Another Related Posts Plugin'>Yet Another Related Posts Plugin</a></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>The advanced WordPress user is intimately familiar with <a href="http://codex.wordpress.org/Template_Tags/query_posts"><code>query_posts</code></a>, the function which controls which posts are displayed in &#8220;The Loop.&#8221; <code>query_posts</code> gives plugin and theme writers the ability to display only posts written in Janary (<code>query_posts("monthnum=1")</code>) or disallow posts from a certain category (<code>query_posts("cat=-529")</code><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>). One of the parameters you can set here is <code>orderby</code> which affects the ordering of the posts returned, with allowed values such as <code>author</code>, <code>date</code>, or <code>title</code>. But what if you want to order your posts in some other order, defined outside of your <code>wp_posts</code> table? Here I&#8217;m going to lay out some thoughts on rolling your own external ordering source for WordPress queries.</p>

<p>In order to introduce an external ordering source, we need to do four things:
1. create the external ordering source,
2. hook up (read &#8220;<code>join</code>&#8221;) the external ordering source
3. make sure we use that order, and
4. make it play nice. ^^</p>

<p>By the way, I&#8217;m going to assume you, dear reader, are PHP-savvy, proficient in MySQL, and already know a little about WordPress. This how-to is not for the PHPhobic.</p>

<p><span id="more-1102"></span></p>

<h3>The ordering source</h3>

<p>For this example, suppose we want to display posts by order of &#8220;interestingness.&#8221; We&#8217;ll just create a table called <code>wp_interestingness</code> with two columns, <code>ID</code> and <code>interestingness</code> and populate it with some data. We&#8217;ll even be nice to our database by making sure the <code>ID</code> is the primary key. Easy.</p>

<h3>Hook up the external ordering source</h3>

<p>When you run a query through <code>query_posts()</code> (or use <code>WP_Query</code>&#8217;s <code>query</code> method<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>), what it&#8217;s doing is taking your special request and translating it into a MySQL statement. This means a query like <code>"monthnum=1"</code> is turned into <code>SELECT ... wp_posts.* FROM wp_posts WHERE 1=1 AND MONTH(wp_posts.post_date)='1' ...</code>. Every different query introduces something new to the basic <code>SELECT</code> command—in this case, the <code>AND MONTH(wp_posts.post_date)='1'</code>.</p>

<p>We first want to introduce the <code>interestingness</code> for each post and that means <code>join</code>ing the new table into the query. We&#8217;ll do this using the <code>posts_join</code> <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference">filter</a>. This filter lets you add a <code>join</code> statement to the MySQL request.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_join'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'my_join_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> my_join_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arg</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$arg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; natural join wp_interestingness &quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$arg</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p>Note that here we&#8217;re using <code>natural join</code> as <code>wp_posts</code> and <code>wp_interestingness</code> have only one key in common, <code>ID</code>, and that&#8217;s exactly the column we want to join them on.</p>

<h3>Use the new order</h3>

<p>Now that we&#8217;ve <code>join</code>ed <code>wp_interestingness</code> in, we can refer to <code>wp_interestingness.interestingness</code> in our query. Note now that, by default, an <code>$wpdb-&gt;posts.post_date</code> will be used to order the posts. We&#8217;ll use another filter here; this time <code>posts_orderby</code>, to patch this part of the query. We&#8217;ll search for the default <code>ORDER BY</code> value and replace it with our own <code>interestingness</code>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_orderby'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'my_orderby_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> my_orderby_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arg</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$arg</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.post_date&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;wp_interestingness.interestingness&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$arg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$arg</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p>By the way, you can now check the resulting MySQL query by <code>echo</code>ing <code>$wp_query-&gt;request</code>. (If you&#8217;re using the <code>WP_Query</code> method I advocated below in footnote (2), you&#8217;ll of course have to change <code>$wp_query</code> to the <code>WP_Query</code> object you&#8217;re using.)</p>

<h3>Learn to play nice ^^</h3>

<p>The instructions above do indeed work, but they also cause some major breakdowns in other functions of your blog. Why? That&#8217;s because the current code will edit your queries for every instance of The Loop: your index page, your archives, and your RSS feeds. You probably only want to search by interestingness in certain situations. What we need is a way to tell our (admittedly stupid) <code>my_join_filter</code> and <code>my_orderby_filter</code> when they should apply their <code>interestingness</code> magic and when they shouldn&#8217;t. There are several ways to set up such a system but here I&#8217;ll lay out one that I feel is particularly elegant. We&#8217;ll set it up so you can actually use <code>query_posts("orderby=interestingness")</code> and it&#8217;ll know what you&#8217;re talking about.</p>

<p>One of the first things that happens in <code>query_posts</code>—indeed, way before even the <code>posts_join</code> and <code>posts_orderby</code> filters—is an action hook called <code>parse_query</code>. This lets us look at the initial state of the <code>WP_Query</code> object as it starts to run. In particular, we can look at the <code>orderby</code> query variable and see if we want to order by <code>interestingness</code>. If we do, we&#8217;ll set a global variable called <code>$use_interestingness_flag</code> to be <code>true</code>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'parse_query'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'set_use_interestingness_flag'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> set_use_interestingness_flag<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$use_interestingness_flag</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'orderby'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'interestingness'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$yarpp_score_override</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #000088;">$yarpp_score_override</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p>Now we just have to edit our filters so they only run when <code>$use_interestingness_flag == true</code>. We also will make sure to turn the flag back off in <code>my_orderby_filter</code>, as it&#8217;s our last filter to run during each query. It&#8217;s just like putting the seat back down after using a unisex bathroom.<sup id="fnref:3"><a href="#fn:3" rel="footnote">3</a></sup></p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_join'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'my_join_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> my_join_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arg</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$use_interestingness_flag</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$use_interestingness_flag</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$arg</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; natural join wp_interestingness &quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$arg</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_orderby'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'my_orderby_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> my_orderby_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arg</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">,</span> <span style="color: #000088;">$use_interestingness_flag</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$use_interestingness_flag</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$arg</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.post_date&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;wp_interestingness.interestingness&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$arg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$use_interestingness_flag</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$arg</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p>This method has a great advantage as you can just set it up once and invoke it whenever you want, even together with other parameters, without any additional code. For example, you can try <code>query_posts("monthnum=1&amp;orderby=interestingness")</code> or <code>query_posts("cat=-529&amp;orderby=interestingness")</code>.</p>

<h3>Conclusion</h3>

<p>Adding an external ordering source to your WordPress post queries can be relatively straightforward if you understand what <code>query_posts</code> does and take advantage of its <a href="http://codex.wordpress.org/Plugin_API">hooks</a>. This tutorial can also serve as the basis for many other patches to <code>WP_Query</code>, not just the <code>orderby</code> parameter. To better understand the way WordPress builds its MySQL queries and the many <code>posts_*</code> filters which you can take advantage of, go to the source: <code>wp-includes/query.php</code>. Finally, you can use the special <code>parse_query</code> hook and global variables as flags to only apply the filters when necessary.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>This, incidentally, is precisely what I do to hide, by default, <a href="http://twitter.com/mitchoyoshitaka/">my tweets</a> in my <code>index.php</code> and <code>archives.php</code>.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>If you&#8217;re going to get serious about rolling your WordPress queries I highly recommend you follow <a href="http://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/">Mark Ghosh&#8217;s advice</a> on initializing another object of the <code>WP_Query</code> class and using the <code>query</code> method, rather than just using the global <code>query_posts</code> function.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:3">
<p>The perceptive reader will note that we are still searching for the string <code>"$wpdb-&gt;posts.post_date"</code> in <code>my_orderby_filter</code>, instead of something like <code>"$wpdb-&gt;posts.interestingness"</code>. That&#8217;s because the <code>orderby</code> value of <code>interestingness</code> is not one of the allowed <code>orderby</code> values (search for <code>$allowed_keys</code> in <code>wp-includes/query.php</code> to see the list). Thus the MySQL <code>ORDER BY</code> value is set to the default of <code>"$wpdb-&gt;posts.post_date"</code> before it gets to the <code>posts_orderby</code> filter. Now you know.&#160;<a href="#fnref:3" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<p>Related posts:</p><ol>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/' rel='bookmark' title='Yet Another Related Posts Plugin 2.0'>Yet Another Related Posts Plugin 2.0</a></li>
<li><a href='http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/' rel='bookmark' title='Markdown for WordPress and bbPress'>Markdown for WordPress and bbPress</a></li>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin/' rel='bookmark' title='Yet Another Related Posts Plugin'>Yet Another Related Posts Plugin</a></li>
</ol>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/how-to/external-orders-in-wordpress-queries/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Keep up with Yet Another Related Posts Plugin with RSS!</title>
		<link>http://mitcho.com/blog/projects/keep-up-with-yet-another-related-posts-plugin-with-rss/</link>
		<comments>http://mitcho.com/blog/projects/keep-up-with-yet-another-related-posts-plugin-with-rss/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 16:43:34 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[how to]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[YARPP]]></category>

		<guid isPermaLink="false">http://mitcho.com/blog/?p=789</guid>
		<description><![CDATA[As more and more people have been using my Yet Another Related Posts Plugin for WordPress, I thought it would be nice to have an RSS feed for users to stay on top of the latest releases. Yet Another Related Posts Plugin version log RSS 2.0 Clicking on a version&#8217;s permalink will let you download [...]
Related posts:<ol>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/' rel='bookmark' title='Yet Another Related Posts Plugin 2.0'>Yet Another Related Posts Plugin 2.0</a></li>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin/' rel='bookmark' title='Yet Another Related Posts Plugin'>Yet Another Related Posts Plugin</a></li>
<li><a href='http://mitcho.com/blog/projects/modifiying-wordpress-plugin-activation-behavior/' rel='bookmark' title='Modifiying WordPress plugin activation behavior'>Modifiying WordPress plugin activation behavior</a></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>As <a href="http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/stats/">more and more people</a> have been using my <a href="/code/yarpp">Yet Another Related Posts Plugin</a> for <a href="http://en.wikipedia.org/wiki/WordPress">WordPress</a>, I thought it would be nice to have an RSS feed for users to stay on top of the latest releases.</p>

<div class="files">
<div class="file rss">
<a href="http://mitcho.com/code/yarpp/yarpp.rss">Yet Another Related Posts Plugin version log</a><br />
<span class="specs">RSS 2.0</span>
</div>
</div>

<p>Clicking on a version&#8217;s permalink will let you download the plugin. Subscribe now and be the first to find out when the upcoming version 2.1 is released!</p>

<p>I decided to semi-automate this RSS-producing process as well. As a plugin developer using <a href="http://wordpress.org/extend">wordpress.org</a>&#8217;s plugin hosting, I sync a local copy of the plugin to their server using <a href="http://en.wikipedia.org/wiki/SVN">SVN</a>. I wrote a <a href="http://en.wikipedia.org/wiki/PHP">PHP</a> script to get the modification date information directly from the local files, parse the version log in the read me, and produce the RSS feed. If there&#8217;s an interest, perhaps I&#8217;ll release this code in the future.</p>
<p>Related posts:</p><ol>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/' rel='bookmark' title='Yet Another Related Posts Plugin 2.0'>Yet Another Related Posts Plugin 2.0</a></li>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin/' rel='bookmark' title='Yet Another Related Posts Plugin'>Yet Another Related Posts Plugin</a></li>
<li><a href='http://mitcho.com/blog/projects/modifiying-wordpress-plugin-activation-behavior/' rel='bookmark' title='Modifiying WordPress plugin activation behavior'>Modifiying WordPress plugin activation behavior</a></li>
</ol>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/projects/keep-up-with-yet-another-related-posts-plugin-with-rss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yet Another Related Posts Plugin 2.0</title>
		<link>http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/</link>
		<comments>http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 15:06:06 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[projects]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Planet]]></category>

		<guid isPermaLink="false">http://mitcho.com/blog/?p=521</guid>
		<description><![CDATA[Yet Another Related Posts Plugin 2.0.5 16&#160;kb - zip Well, it&#8217;s been a while since I updated my plugin YARPP&#8212;in my humble opinion the best related posts plugin for WordPress. ^^ Today I release version 2.0, incorporating a number of important requests and bug fixes: New algorithm which considers tags and categories, by frequent request [...]
Related posts:<ol>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin/' rel='bookmark' title='Yet Another Related Posts Plugin'>Yet Another Related Posts Plugin</a></li>
<li><a href='http://mitcho.com/blog/projects/modifiying-wordpress-plugin-activation-behavior/' rel='bookmark' title='Modifiying WordPress plugin activation behavior'>Modifiying WordPress plugin activation behavior</a></li>
<li><a href='http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/' rel='bookmark' title='Markdown for WordPress and bbPress'>Markdown for WordPress and bbPress</a></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="files">
<div class="file zip">
<a href="http://downloads.wordpress.org/plugin/yet-another-related-posts-plugin.2.0.5.zip">Yet Another Related Posts Plugin 2.0.5</a><br />
<span class="specs">16&#160;kb - zip</span>
</div>
</div>

<p>Well, it&#8217;s been a while since I updated my plugin <a href="http://mitcho.com/code/yarpp/">YARPP</a>&#8212;in my humble opinion the best related posts plugin for <a href="http://www.wordpress.org">WordPress</a>. ^^ Today I release <a href="http://downloads.wordpress.org/plugin/yet-another-related-posts-plugin.2.0.zip">version 2.0</a>, incorporating a number of important requests and bug fixes:</p>

<ul>
<li>New algorithm which considers tags and categories, by frequent request</li>
<li>Order by score, date, or title, <a href="http://wordpress.org/support/topic/158459">by request</a></li>
<li>Excluding certain tags or categories, <a href="http://wordpress.org/support/topic/161263">by request</a></li>
<li>Sample output displayed in the options screen</li>
<li>Bugfix: <a href="http://wordpress.org/support/topic/155034?replies=5">an excerpt length bug</a></li>
<li>Bugfix: now compatible with the following plugins:

<ul>
<li>diggZEt</li>
<li>WP-Syntax</li>
<li>Viper&#8217;s Video Quicktags</li>
<li>WP-CodeBox</li>
<li>WP shortcodes</li>
</ul></li>
</ul>

<p>Check out the <a href="http://mitcho.com/code/yarpp/">Yet Another Related Posts Plugin page on this site</a>, <a href="http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/">the page on wordpress.org</a>, or <a href="http://downloads.wordpress.org/plugin/yet-another-related-posts-plugin.2.0.zip">download it directly now</a>!</p>
<p>Related posts:</p><ol>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin/' rel='bookmark' title='Yet Another Related Posts Plugin'>Yet Another Related Posts Plugin</a></li>
<li><a href='http://mitcho.com/blog/projects/modifiying-wordpress-plugin-activation-behavior/' rel='bookmark' title='Modifiying WordPress plugin activation behavior'>Modifiying WordPress plugin activation behavior</a></li>
<li><a href='http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/' rel='bookmark' title='Markdown for WordPress and bbPress'>Markdown for WordPress and bbPress</a></li>
</ol>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/projects/yet-another-related-posts-plugin-20/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Markdown for WordPress and bbPress</title>
		<link>http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/</link>
		<comments>http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/#comments</comments>
		<pubDate>Wed, 21 May 2008 14:07:28 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[projects]]></category>
		<category><![CDATA[bbPress]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Markdown]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Planet]]></category>

		<guid isPermaLink="false">http://mitcho.com/blog/?p=274</guid>
		<description><![CDATA[Markdown for WordPress and bbPress 1.0 30&#160;kb - zip I like many others am a big fan of John Gruber&#8217;s Markdown, a simple typesetting spec for entering text in a clean, legible plain-text fashion and outputting to (X)HTML. Michel Fortin did the fabulous job of porting the Markdown engine to PHP, making it a plugin [...]
Related posts:<ol>
<li><a href='http://mitcho.com/blog/projects/modifiying-wordpress-plugin-activation-behavior/' rel='bookmark' title='Modifiying WordPress plugin activation behavior'>Modifiying WordPress plugin activation behavior</a></li>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin/' rel='bookmark' title='Yet Another Related Posts Plugin'>Yet Another Related Posts Plugin</a></li>
<li><a href='http://mitcho.com/blog/projects/introducing-smartdate/' rel='bookmark' title='Introducing Smartdate'>Introducing Smartdate</a></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<div class="files">
<div class="file zip">
<a href="http://downloads.wordpress.org/plugin/markdown-for-wordpress-and-bbpress.1.0.zip">Markdown for WordPress and bbPress 1.0</a><br />
<span class="specs">30&#160;kb - zip</span>
</div>
</div>

<p>I like many others am a big fan of John Gruber&#8217;s <a href="http://daringfireball.net/projects/markdown/">Markdown</a>, a simple typesetting spec for entering text in a clean, legible plain-text fashion and outputting to (X)HTML. <a href="http://michelf.com/projects/php-markdown/">Michel Fortin</a> did the fabulous job of porting the Markdown engine to PHP, making it a plugin for <a href="http://wordpress.org/">WordPress</a>, <a href="http://www.bblog.com/">bBlog</a>, and <a href="http://textpattern.com/">TextPattern</a>.</p>

<p>I&#8217;ve been using Markdown for all my blog posts here. Recently, though, I was in charge of a <a href="http://www.bbpress.org">bbPress</a> bulletin board (the &#8220;less is more&#8221; sister project to WordPress) for the Shoreland <a href="http://mitcho.com/blog/2008/05/08/scav-hunt/">Scav Hunt team</a>, and wanted to use Markdown formatting there. And <a href="http://bbpress.org/forums/topic/markdown">I wasn&#8217;t the only one wanting to do this</a>.</p>

<p>With some experimenting and research into the filters in the bbPress text flow (different than <a href="http://michelf.com/weblog/2005/wordpress-text-flow-vs-markdown/">the WordPress one</a>), I was able to make Markdown work in bbPress. This involved adding a special bbPress plugin wrapper to Michel Fortin&#8217;s <a href="http://bbpress.org/forums/topic/markdown/extra/">PHP Markdown Extra</a>. I&#8217;ve rereleased this plugin as <strong>Markdown for WordPress and bbPress</strong>, available at both <a href="http://wordpress.org/extend/plugins/markdown-for-wordpress-and-bbpress/">wordpress.org</a> and <a href="http://bbpress.org/plugins/topic/markdown-for-wordpress-and-bbpress/">bbpress.org</a>. Enjoy!</p>
<p>Related posts:</p><ol>
<li><a href='http://mitcho.com/blog/projects/modifiying-wordpress-plugin-activation-behavior/' rel='bookmark' title='Modifiying WordPress plugin activation behavior'>Modifiying WordPress plugin activation behavior</a></li>
<li><a href='http://mitcho.com/blog/projects/yet-another-related-posts-plugin/' rel='bookmark' title='Yet Another Related Posts Plugin'>Yet Another Related Posts Plugin</a></li>
<li><a href='http://mitcho.com/blog/projects/introducing-smartdate/' rel='bookmark' title='Introducing Smartdate'>Introducing Smartdate</a></li>
</ol>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/projects/markdown-for-wordpress-and-bbpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yet Another Related Posts Plugin</title>
		<link>http://mitcho.com/blog/projects/yet-another-related-posts-plugin/</link>
		<comments>http://mitcho.com/blog/projects/yet-another-related-posts-plugin/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 13:49:20 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[metablog]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[threshold]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Planet]]></category>
		<category><![CDATA[YARPP]]></category>

		<guid isPermaLink="false">http://mitcho.com/blog/2007/12/29/yet-another-related-posts-plugin/</guid>
		<description><![CDATA[UPDATE: This posting is now outdated&#8230; for the latest information on YARPP, please visit YARPP&#8217;s very own page on my site, or its page on wordpress.org. If you have questions, please submit on the wordpress.org forum. Thanks! Description Today I&#8217;m releasing Yet Another Related Posts Plugin (YARPP1) 1.0 for WordPress. It&#8217;s the result of some [...]
Related posts:<ol>
<li><a href='http://mitcho.com/blog/projects/introducing-smartdate/' rel='bookmark' title='Introducing Smartdate'>Introducing Smartdate</a></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<h3>UPDATE:</h3>

<p>This posting is now outdated&#8230; for the latest information on YARPP, please visit <a href="/code/yarpp/">YARPP&#8217;s very own page</a> on my site, or <a href="http://wordpress.org/extend/plugins/yet-another-related-posts-plugin">its page on <code>wordpress.org</code></a>. If you have questions, please submit on <a href="http://wordpress.org/tags/yet-another-related-posts-plugin">the <code>wordpress.org</code> forum</a>. Thanks!</p>

<h3>Description</h3>

<p>Today I&#8217;m releasing Yet Another Related Posts Plugin (YARPP<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>) 1.0 for <a href="http://www.wordpress.org">WordPress</a>. It&#8217;s the result of some tinkering with <a href="http://peter.mapledesign.co.uk/weblog/archives/wordpress-related-posts-plugin">Peter Bowyer&#8217;s version</a> of <a href="http://wasabi.pbwiki.com/Related%20Entries">Alexander Malov &amp; Mike Lu&#8217;s Related Entries plugin</a>. Modifications made include:</p>

<ol>
<li><em>Limiting by a threshold</em>: Peter Bowyer did the great work of making the algorithm use <a href="http://en.wikipedia.org/wiki/mysql">mysql</a>&#8217;s <a href="http://dev.mysql.com/doc/en/Fulltext_Search.html">fulltext search</a> score to identify related posts. But it currently just displayed, for example, the top 5 most &#8220;relevant&#8221; entries, even if some of them weren&#8217;t at all similar. Now you can set a threshold limit<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup> for relevance, and you get more related posts if there are more related posts and less if there are less. Ha!</li>
<li><em>Being a better plugin citizen</em>: now it doesn&#8217;t require the user to click some sketchy button to <code>alter</code> the database and enable a <code>fulltext key</code>. Using <a href="http://codex.wordpress.org/Function_Reference/register_activation_hook"><code>register_activation_hook</code></a>, it does it automagically on plugin activation. Just install and go!</li>
<li><em>Miscellany</em>: a nicer options screen, displaying the fulltext match score on output for admins, an option to allow related posts from the future, a couple bug fixes, etc.</li>
</ol>

<h3>Installation</h3>

<p>Just put it in your <code>/wp-content/plugins/</code> directory, activate, and then drop the <code>related_posts</code> function in your <a href="http://codex.wordpress.org/The_Loop">WP loop</a>. Change any options in the Related Posts (YARPP) Options pane in Admin > Plugins.</p>

<p>You can override any options in an individual instance of <code>related_posts</code> using the following syntax:</p>

<blockquote>
  <p>`related_posts(limit, threshold, before title, after title, show excerpt, len, before excerpt, after excerpt, show pass posts, past only, show score);</p>
</blockquote>

<p>Most of these should be self-explanatory. They&#8217;re also in the same order as the options on the YARPP Options pane.</p>

<p>Example: <code>related_posts(10, null, 'title: ')</code> changes the maximum related posts number to 10, keeps the default threshold from the Options pane, and adds <code>title:</code> to the beginning of every title.</p>

<p>There&#8217;s also a <code>related_posts_exist)</code> function. It has three optional arguments to override the defaults: a threshold, the past only boolean, and the show password-protected posts boolean.</p>

<h3>Examples</h3>

<p>For a barebones setup, just drop <code>&lt;?php related_posts(); ?&gt;</code> right after <code>&lt;?php the_content() ?&gt;</code>.</p>

<p>On my own blog I use the following code with <code>&lt;li&gt;</code> and <code>&lt;/li&gt;</code> as the before/after entry options:</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>related_posts_exist<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;p&gt;Related posts:
&lt;ol&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> related_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/ol&gt;
&lt;/p&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;p&gt;No related posts.&lt;/p&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<h3>Coming soon (probably)</h3>

<ol>
<li>Incorporation of tags and categories in the algorithm. I&#8217;ve gotten the code working, but I still need to think about what the most natural algorithm would be for weighing these factors against the mysql fulltext score currently used (and works pretty well, I must say).</li>
<li>Um, something else! Let me know if you have any suggestions for improvement. ^^</li>
</ol>

<h3>Version log</h3>

<p>1.0   Initial upload (20071229)</p>

<p>1.0.1 Bugfix: 1.0 assumed you had Markdown installed (20070105)</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>Pronounced &#8220;yarp!&#8221;, kind of like this, but maybe with a little more joy:<br /><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/7cOuGJMRORw&#038;rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/7cOuGJMRORw&#038;rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>Did you know that threshold has only two h&#8217;s!? I&#8217;m incensed and just went through and replaced all the instances of <code>threshhold</code> in my code. It&#8217;s really not a thresh-hold!?&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<p>Related posts:</p><ol>
<li><a href='http://mitcho.com/blog/projects/introducing-smartdate/' rel='bookmark' title='Introducing Smartdate'>Introducing Smartdate</a></li>
</ol>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/projects/yet-another-related-posts-plugin/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Introducing Smartdate</title>
		<link>http://mitcho.com/blog/projects/introducing-smartdate/</link>
		<comments>http://mitcho.com/blog/projects/introducing-smartdate/#comments</comments>
		<pubDate>Tue, 27 Nov 2007 12:47:04 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[metablog]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[smartdate]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Planet]]></category>

		<guid isPermaLink="false">http://mitcho.com/blog/2007/11/27/introducing-smartdate/</guid>
		<description><![CDATA[I recently have been working on a WordPress plugin called WP-Smartdate and I&#8217;m happy to say that it is hosted at wordpress.org starting today. As some people have noticed, my blog recently has included little links on word like &#8220;yesterday,&#8221; with a machine readable version of the date reference (called a &#8220;microformat&#8221; in the biz). [...]
Related posts:<ol>
<li><a href='http://mitcho.com/blog/metablog/yes-i-have-a-blog/' rel='bookmark' title='Yes, I have a blog'>Yes, I have a blog</a></li>
<li><a href='http://mitcho.com/blog/life/how-i-name-my-kids/' rel='bookmark' title='How I name my kids'>How I name my kids</a></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I recently have been working on a <a href="http://www.wordpress.org">WordPress</a> plugin called WP-Smartdate and I&#8217;m happy to say that it is <a href="http://wordpress.org/extend/plugins/wp-smartdate/">hosted at wordpress.org</a> starting today. As some people have noticed, my blog recently has included little links on word like &#8220;yesterday,&#8221; with a machine readable version of the date reference (called a &#8220;<a href="http://microformats.org/">microformat</a>&#8221; in the biz). Download the plugin and get started!</p>

<div class="files">
<div class="file zip">
<a href="http://downloads.wordpress.org/plugin/wp-smartdate.0.1.zip">WP-Smartdate 0.1</a><br />
<span class="specs">4&#160;kb - zip</span>
</div>
</div>

<p>This blog post describes release 0.1&#8230; For the latest description, check out the <a href="http://wordpress.org/extend/plugins/wp-smartdate/">WP-Smartdate plugin page</a> or <a href="http://mitcho.com/code">mitcho.com/code</a>.</p>

<p>Please comment! I would love to hear your feedback on the plugin.</p>

<h2>Description</h2>

<p>WP-Smartdate looks for <em>relative date expressions</em> in your blog posts, such as &#8220;tomorrow,&#8221; &#8220;this coming Monday,&#8221; &#8220;last Friday,&#8221; and adds the date reference (like &#8220;2007-11-26&#8221;) as a machine-readable <a href="http://microformats.org/wiki/datetime-design-pattern">microformat</a>.</p>

<h3>Why Smartdate?</h3>

<p>WP-Smartdate was created for three simple audiences:</p>

<ol>
<li><em>For the machine:</em> While many professional information retrieval algorithms go far beyond the scope of this program, smartdate helps the process along by adding machine-readable tags to relative date expressions.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> In addition, these machine tags, in turn, help the human: a search on Google for &#8220;November 7th, 2007,&#8221; for example, will not pull up a document talking about &#8220;yesterday,&#8221; written on the 8th, but it will pull up the smartdate output of <code>2007-11-07</code>.</li>
<li><em>For the human reader:</em> Blog posts are often written in the &#8220;now,&#8221; using relative time expressions without concern for how the text will be read in the future. WP-Smartdate makes such posts easier to read and comprehend temporally<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.</li>
<li><em>For <a href="http://mitcho.com">me</a></em>: Because I think this sort of thing is fun!</li>
</ol>

<h3>A typology of smartdate date expressions</h3>

<p>The following types of expressions are resolved with respect to the speech time&#8212;in WP-Smartdate&#8217;s case, the blog post date.</p>

<ol>
<li><em>simple references</em>: &#8220;yesterday,&#8221; &#8220;today,&#8221; &#8220;tomorrow,&#8221;</li>
<li><em>next/last <abbr title="day of the week">DOTW</abbr> expressions</em>: &#8220;next Friday,&#8221; &#8220;this past Sunday,&#8221; &#8220;this Monday&#8221;</li>
</ol>

<h3>For the future</h3>

<ul>
<li><em>static dates</em>: &#8220;January 1st, 2007&#8221;</li>
<li><em>duration shift expressions</em>: &#8220;5 days ago,&#8221; &#8220;fourscore and seven years ago&#8221;</li>
<li><em>day of the week shifts</em>: &#8220;2 Fridays ago&#8221;</li>
<li>clean up the code!</li>
</ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>One could argue that relative dates are a perfect place to use the <code>abbr</code> tag, as they are a sort of natural-language shortcut for more static temporal expressions. In fact, WP-Smartdate&#8217;s output also follows the <a href="http://microformats.org/wiki/datetime-design-pattern">datetime microformat design pattern draft</a> with two caveats:
1. Unfortunately, the datetime <a href="http://microformats.org/wiki/semantic-class-names">semantic class</a> has not yet been set as the standard is a draft. WP-Smartdate uses <code>datetime</code>. See the <a href="http://microformats.org/wiki/rest/datatypes#Proposal">Date and Time datatype proposal</a> for more information.
2. The <a href="http://microformats.org/wiki/rest/datatypes#Proposal">current recommendation for datetime</a> pushes for following the <a href="http://www.w3.org/TR/NOTE-datetime">W3C datetime profile</a>, which does not support the <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO-8601 time interval</a> specification, which <del>is</del> will be used by WP-Smartdate.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>Even though <a href="http://www.smackthemouse.com/20040108">the <code>abbr</code> tag should only be used for machine reading</a>.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<p>Related posts:</p><ol>
<li><a href='http://mitcho.com/blog/metablog/yes-i-have-a-blog/' rel='bookmark' title='Yes, I have a blog'>Yes, I have a blog</a></li>
<li><a href='http://mitcho.com/blog/life/how-i-name-my-kids/' rel='bookmark' title='How I name my kids'>How I name my kids</a></li>
</ol>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/projects/introducing-smartdate/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

