<?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>Special Operations &#187; random post order</title>
	<atom:link href="http://www.specialops.co.nz/tag/random-post-order/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.specialops.co.nz</link>
	<description>Web development, design, print &#38; video in Auckland, New Zealand</description>
	<lastBuildDate>Mon, 14 Nov 2011 00:28:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Random Post Order in WordPress</title>
		<link>http://www.specialops.co.nz/blog/random-post-order-in-wordpress/</link>
		<comments>http://www.specialops.co.nz/blog/random-post-order-in-wordpress/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 06:12:34 +0000</pubDate>
		<dc:creator>John Gillespie</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[get_posts]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[query_posts]]></category>
		<category><![CDATA[random post order]]></category>
		<category><![CDATA[templates]]></category>

		<guid isPermaLink="false">http://www.specialops.co.nz/?p=738</guid>
		<description><![CDATA[Randomising your post order in WordPress should be as easy as hitting Command-Shift-R to hard refresh your page, but depending on your theme set-up, there are a number of approaches to consider, some more random than others.]]></description>
			<content:encoded><![CDATA[<p class="intro">Randomising your post order in <a title="WordPress" href="http://wordpress.org/">WordPress</a> should be as easy as hitting Command-Shift-R to hard refresh your page, but depending on your theme set-up, there are a number of approaches to consider, some more random than others.</p>
<p><img class="alignright size-medium wp-image-431 no-border" title="WordPress CMS and themes by Special Operations" src="http://www.specialops.co.nz/wp/wp-content/uploads/2009/06/wordpress-com-300x300.png" alt="WordPress CMS and themes by Special Operations" width="210" height="210" />Welcome to the life of a web-developer. “Can you make my bing-bong random?” says the client, but adding, “&#8230;this won’t cost me anything extra will it? I mean, after all, you can just Ctrl-Click your fingers and make it happen?”</p>
<p>Yes, some things are very simple in development and programming, but that doesn&#8217;t mean that hours, days, weeks and years do not go into making them so. Like random post order in WordPress. It’s truly simple once you know how, but knowing how could, unguided, take hours of research&#8230;</p>
<h3>The Plugin Approach</h3>
<p>One of the great things about using WordPress as a <a href="http://www.specialops.co.nz/cms" title="Content Mangement Systems by Special Operations">CMS</a>—perhaps even the greatest—is that there is more than likely an already written plugin for whatever feature you seek. More than likely, but in the case of random post order, there are some limitations to consider&#8230;</p>
<h4>Custom Post Order Plugin</h4>
<p>The <a title="Custom Post Order Plugin" href="http://wordpress.org/extend/plugins/custom-post-order/">Custom Post Order Plugin</a> is an excellent plugin for customising the order of your WordPress posts, with a variety of ordering options including:</p>
<ul>
<li>post date;</li>
<li>post title;</li>
<li>post author;</li>
<li>last time modified;</li>
<li>post slug;</li>
<li>ascending or descending order.</li>
</ul>
<p>Sadly however the Custom Post Order Plugin doesn&#8217;t allow for randomisation, so we will have to scratch it off our list.</p>
<h4>Advanced Random Post Plugin</h4>
<p>Only “officially” compatible with WordPress 2.3.3, and only at the time of writing developed to version 0.2, Daniele Salamina’s <a title="Advanced Random Post Plugin" href="http://www.danielesalamina.it/advanced-random-post#english">Advanced Random Post Plugin</a> still works exactly as advertised, albeit with a few limitations:</p>
<ul>
<li>it only allows a maximum of 5 random posts;</li>
<li>it isn&#8217;t compatible with sticky posts (to be fair these didn’t exist in v2.3), although it allows you to select a post position from where the randomisation takes effect, which may in some circumstances be an acceptable workaround;</li>
<li>it wreaked havoc with a jQuery based slider, in this particular case the slider included in WooThemes’s <a title="Daily Edition theme by WooThemes" href="http://www.woothemes.com/2009/09/daily-edition/"><em>Daily Edition</em></a> theme (and many others).</li>
</ul>
<p>WordPress moves, and updates, extremely quickly, and early 2008—the last time this plugin was updated—is in WordPress terms a very long time ago. Therefore, what is more than likely a partial incompatibility between the CMS and plugin—WordPress 2.9 is a very different beast indeed from v2.3—may lead you to scratch this plugin from your set-up completely.</p>
<h4>Random Posts Plugin</h4>
<p>Rob Marsh’s <a title="Random Posts Plugin" href="http://rmarsh.com/plugins/random-posts/">Random Posts Plugin</a> is an excellent plugin from a family of excellent plugins (<a title="Popular Posts" href="http://rmarsh.com/plugins/popular-posts-plugin/">Popular Posts</a>, <a href="http://rmarsh.com/plugins/similar-posts/" title="Similar Posts"> Similar Posts</a>, <a title="Recent Posts" href="http://rmarsh.com/plugins/recent-posts/"> Recent Posts</a>), with true everything-plus-the-kitchen-sink customisation possible. Able to be deployed as both a sidebar widget and a PHP function, this plugin possesses a near complete language for virtually limitless customisation, including the capacity to render HTML and PHP.</p>
<p>Without extensive customisation however, the Random Post Plugin is limited to generating a single iteration list of posts, outside of the WordPress <a href="http://codex.wordpress.org/The_Loop">Loop</a>, and therefore is not a solution if it is the The Loop itself which you are attempting to randomise, i.e. make random all your WordPress posts, potentially across multiple ‘pages’.</p>
<h3>The Template Approach</h3>
<p>While there is no random post order option available (yet) in WordPress’s increasingly well-designed <a href="http://codex.wordpress.org/Administration_Panels" title="WordPress Dashboard">Dashboard</a>, as of v2.5 randomisation has been included under the hood as a part of the <a title="WordPress Codex" href="http://codex.wordpress.org/Main_Page">template language</a>, and can be invoked as a parameter of both the <code>get_posts</code> and <code>query_posts</code> template tags. </p>
<p>This is a far more elegant solution than a plug-in, as it utilises a functionality of WordPress that is already built-in, and doesn&#8217;t add an extra layer code with the potential for conflict, bloating and deprecation.</p>
<h4>Random Posts Template Example</h4>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;"> $args = array(
	'numberposts' =&gt; -1,
	'post_parent' =&gt; $post-&gt;ID,
        'orderby' =&gt; 'rand'
         );
 query_posts($args);</pre></div></div>

<h4>More information on WordPress Templates</h4>
<p>More detailed documentation on using both <code>query_posts</code> and <code>get_posts</code> can be found at <a href="http://codex.wordpress.org/Template_Tags/get_posts">WordPress.org</a>.</p>
<h3>Command-Shift what you say?</h3>
<p>Yes, all right, if you&#8217;re coding for the Evil Empire, Ctrl-Shift-R or F5 will also do the needful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.specialops.co.nz/blog/random-post-order-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

