<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Random Post snippet</title>
	<atom:link href="http://ottopress.com/2011/random-post-snippet/feed/" rel="self" type="application/rss+xml" />
	<link>http://ottopress.com/2011/random-post-snippet/</link>
	<description>You have to use an Ottopress to get fresh squeezed Otto.</description>
	<lastBuildDate>Tue, 21 May 2013 09:48:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6-beta3-24284</generator>
	<item>
		<title>By: Simple Solution Of Random Redirection In WordPress &#124; WordPress Planet</title>
		<link>http://ottopress.com/2011/random-post-snippet/comment-page-1/#comment-11269</link>
		<dc:creator>Simple Solution Of Random Redirection In WordPress &#124; WordPress Planet</dc:creator>
		<pubDate>Mon, 01 Oct 2012 12:17:39 +0000</pubDate>
		<guid isPermaLink="false">http://ottopress.com/?p=709#comment-11269</guid>
		<description><![CDATA[[...] “Random Post Snippet,” Otto on WordPress [...]]]></description>
		<content:encoded><![CDATA[<p>[...] “Random Post Snippet,” Otto on WordPress [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Random Redirection in WordPress &#124; Smashing WordPress</title>
		<link>http://ottopress.com/2011/random-post-snippet/comment-page-1/#comment-10747</link>
		<dc:creator>Random Redirection in WordPress &#124; Smashing WordPress</dc:creator>
		<pubDate>Sun, 29 Apr 2012 09:13:39 +0000</pubDate>
		<guid isPermaLink="false">http://ottopress.com/?p=709#comment-10747</guid>
		<description><![CDATA[[...] “Random Post Snippet,” Otto on WordPress [...]]]></description>
		<content:encoded><![CDATA[<p>[...] “Random Post Snippet,” Otto on WordPress [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: emmanuel</title>
		<link>http://ottopress.com/2011/random-post-snippet/comment-page-1/#comment-10506</link>
		<dc:creator>emmanuel</dc:creator>
		<pubDate>Tue, 07 Feb 2012 07:39:17 +0000</pubDate>
		<guid isPermaLink="false">http://ottopress.com/?p=709#comment-10506</guid>
		<description><![CDATA[By the way,

I implemented the code in my website and it is working like a charm! I now have a button leading to a new random post from the same category (see code below)
------------------------------------------------------------------
add_action(&#039;init&#039;,&#039;random_add_rewrite&#039;);
function random_add_rewrite() {
       global $wp;
       $wp-&gt;add_query_var(&#039;random&#039;);
       add_rewrite_rule(&#039;random/?$&#039;, &#039;index.php?random=1&#039;, &#039;top&#039;);
}

add_action(&#039;template_redirect&#039;,&#039;random_template&#039;);
function random_template() {
       if (get_query_var(&#039;random&#039;) == 1) {
               $args = array( &#039;numberposts&#039; =&gt; 1, &#039;orderby&#039; =&gt; rand, &#039;category__in&#039; =&gt; 11 );
	       $posts = get_posts( $args );
               foreach($posts as $post) {
                       $link = get_permalink($post);
               }
               wp_redirect($link,307);
               exit;
       }
}
------------------------------------------------------------------

Now I have a question: 
What do i need to change to be able to add another button to do the same in yet another category?
I guess the code should be the same but i need to chane the &quot;random&quot; at the end of my url by &quot;random1&quot; or something, and change the category number.
I am trying to find the bit of code i need to change to affect only the word i should put at the end and the category.
Would i need to add the whole snippet below the first one?

Thanks for the help! :)]]></description>
		<content:encoded><![CDATA[<p>By the way,</p>
<p>I implemented the code in my website and it is working like a charm! I now have a button leading to a new random post from the same category (see code below)<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
add_action(&#8216;init&#8217;,'random_add_rewrite&#8217;);<br />
function random_add_rewrite() {<br />
       global $wp;<br />
       $wp-&gt;add_query_var(&#8216;random&#8217;);<br />
       add_rewrite_rule(&#8216;random/?$&#8217;, &#8216;index.php?random=1&#8242;, &#8216;top&#8217;);<br />
}</p>
<p>add_action(&#8216;template_redirect&#8217;,'random_template&#8217;);<br />
function random_template() {<br />
       if (get_query_var(&#8216;random&#8217;) == 1) {<br />
               $args = array( &#8216;numberposts&#8217; =&gt; 1, &#8216;orderby&#8217; =&gt; rand, &#8216;category__in&#8217; =&gt; 11 );<br />
	       $posts = get_posts( $args );<br />
               foreach($posts as $post) {<br />
                       $link = get_permalink($post);<br />
               }<br />
               wp_redirect($link,307);<br />
               exit;<br />
       }<br />
}<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Now I have a question:<br />
What do i need to change to be able to add another button to do the same in yet another category?<br />
I guess the code should be the same but i need to chane the &#8220;random&#8221; at the end of my url by &#8220;random1&#8243; or something, and change the category number.<br />
I am trying to find the bit of code i need to change to affect only the word i should put at the end and the category.<br />
Would i need to add the whole snippet below the first one?</p>
<p>Thanks for the help! <img src='http://ottopress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: emmanuel</title>
		<link>http://ottopress.com/2011/random-post-snippet/comment-page-1/#comment-10496</link>
		<dc:creator>emmanuel</dc:creator>
		<pubDate>Mon, 06 Feb 2012 11:01:01 +0000</pubDate>
		<guid isPermaLink="false">http://ottopress.com/?p=709#comment-10496</guid>
		<description><![CDATA[You&#039;re a modern superhero!]]></description>
		<content:encoded><![CDATA[<p>You&#8217;re a modern superhero!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jB</title>
		<link>http://ottopress.com/2011/random-post-snippet/comment-page-1/#comment-10287</link>
		<dc:creator>jB</dc:creator>
		<pubDate>Sun, 18 Dec 2011 22:37:36 +0000</pubDate>
		<guid isPermaLink="false">http://ottopress.com/?p=709#comment-10287</guid>
		<description><![CDATA[Okay, makes sense - just plain coding-habits :)]]></description>
		<content:encoded><![CDATA[<p>Okay, makes sense &#8211; just plain coding-habits <img src='http://ottopress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Otto</title>
		<link>http://ottopress.com/2011/random-post-snippet/comment-page-1/#comment-10286</link>
		<dc:creator>Otto</dc:creator>
		<pubDate>Sun, 18 Dec 2011 22:24:04 +0000</pubDate>
		<guid isPermaLink="false">http://ottopress.com/?p=709#comment-10286</guid>
		<description><![CDATA[No reason. Queries return arrays, and foreach is a pretty normal way of dealing with arrays. 90% of code I&#039;m writing falls into a pattern. When I write queries, then I loop through the results, even if there&#039;s only one result.]]></description>
		<content:encoded><![CDATA[<p>No reason. Queries return arrays, and foreach is a pretty normal way of dealing with arrays. 90% of code I&#8217;m writing falls into a pattern. When I write queries, then I loop through the results, even if there&#8217;s only one result.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jB</title>
		<link>http://ottopress.com/2011/random-post-snippet/comment-page-1/#comment-10285</link>
		<dc:creator>jB</dc:creator>
		<pubDate>Sun, 18 Dec 2011 22:07:31 +0000</pubDate>
		<guid isPermaLink="false">http://ottopress.com/?p=709#comment-10285</guid>
		<description><![CDATA[Very nice.

Why the foreach() instead of just [php]wp_redirect( get_permalink( $posts[&#039;0&#039;] ), 307 );[/php] ?]]></description>
		<content:encoded><![CDATA[<p>Very nice.</p>
<p>Why the foreach() instead of just
<pre class="brush: php; title: ; notranslate">wp_redirect( get_permalink( $posts['0'] ), 307 );</pre>
<p> ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Otto</title>
		<link>http://ottopress.com/2011/random-post-snippet/comment-page-1/#comment-10135</link>
		<dc:creator>Otto</dc:creator>
		<pubDate>Fri, 11 Nov 2011 16:57:51 +0000</pubDate>
		<guid isPermaLink="false">http://ottopress.com/?p=709#comment-10135</guid>
		<description><![CDATA[The get_posts function can take either parameter, actually. The &quot;numberposts&quot; parameter is the older version of that, still there for backwards compatibility. I tend to use it whenever using get_posts, but either will work.]]></description>
		<content:encoded><![CDATA[<p>The get_posts function can take either parameter, actually. The &#8220;numberposts&#8221; parameter is the older version of that, still there for backwards compatibility. I tend to use it whenever using get_posts, but either will work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rami</title>
		<link>http://ottopress.com/2011/random-post-snippet/comment-page-1/#comment-10105</link>
		<dc:creator>rami</dc:creator>
		<pubDate>Sun, 06 Nov 2011 13:00:34 +0000</pubDate>
		<guid isPermaLink="false">http://ottopress.com/?p=709#comment-10105</guid>
		<description><![CDATA[isn&#039;t it &quot;posts_per_page&quot; instead of &quot;numberposts&quot;?]]></description>
		<content:encoded><![CDATA[<p>isn&#8217;t it &#8220;posts_per_page&#8221; instead of &#8220;numberposts&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Otto</title>
		<link>http://ottopress.com/2011/random-post-snippet/comment-page-1/#comment-10088</link>
		<dc:creator>Otto</dc:creator>
		<pubDate>Fri, 04 Nov 2011 03:16:17 +0000</pubDate>
		<guid isPermaLink="false">http://ottopress.com/?p=709#comment-10088</guid>
		<description><![CDATA[Try the &quot;category__in&quot; parameter.]]></description>
		<content:encoded><![CDATA[<p>Try the &#8220;category__in&#8221; parameter.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Object Caching 423/439 objects using xcache

 Served from: ottodestruct.com @ 2013-05-21 16:27:25 by W3 Total Cache -->