<?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>Hair Tyson</title>
	<atom:link href="http://hairtyson.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hairtyson.com</link>
	<description>Its all about Me and My Designs</description>
	<lastBuildDate>Tue, 28 Jul 2009 10:24:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A Flower Of My Garden</title>
		<link>http://hairtyson.com/a-flower-of-my-garden/</link>
		<comments>http://hairtyson.com/a-flower-of-my-garden/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 10:22:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://hairtyson.com/?p=22</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-medium wp-image-24" title="Tropical Flower 1" src="http://hairtyson.com/wp-content/uploads/2009/07/Tropical-Flower-1-300x225.jpg" alt="Tropical Flower 1" width="416" height="311" /></p>
]]></content:encoded>
			<wfw:commentRss>http://hairtyson.com/a-flower-of-my-garden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Avoid Duplicate Posts</title>
		<link>http://hairtyson.com/how-to-avoid-duplicate-posts/</link>
		<comments>http://hairtyson.com/how-to-avoid-duplicate-posts/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 10:07:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://hairtyson.com/?p=13</guid>
		<description><![CDATA[A reader writes in:
I’m developing a new theme and I’m having trouble getting duplicate posts from showing when running two loops (one standard loop and one from a specific category). Even when I copied the specific code from directly from the codex, it was not working.
The Codex article the reader mentioned was regarding the Loop. [...]]]></description>
			<content:encoded><![CDATA[<p>A reader writes in:</p>
<blockquote><p>I’m developing a new theme and I’m having trouble getting duplicate posts from showing when running two loops (one standard loop and one from a specific category). Even when I copied the specific code from directly from the codex, it was not working.</p></blockquote>
<p>The Codex article the reader mentioned <a href="http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action">was regarding the Loop</a>.  Although the example shows how to avoid a single duplicate post, it doesn’t show how to avoid duplicating multiple posts.</p>
<p>Here’s how to show two individual loops without duplicating posts in either loop.</p>
<h3>Step 1:  Add a ‘posts_where’ Function</h3>
<p>A <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference">WordPress filter</a> is needed to accomplish this, and we’re going to be tapping into the ‘<strong>posts_where</strong>‘ filter.</p>
<p>The reason being is we need to modify the query used for the loop and exclude some posts.</p>
<p>Here’s the function we’ll be using called <strong>post_strip</strong>:</p>
<blockquote><p><code> </code></p>
<pre>function post_strip($where) {
	global $myPosts, $wpdb;
	$where .= " AND $wpdb-&gt;posts.ID not in($myPosts) ";
	return $where;
}</pre>
</blockquote>
<p>In the above code, I use a global variable called <strong>$myPosts</strong>, which is comma-separated string of post IDs to exclude.</p>
<h3>Step 2:  Start the First Loop</h3>
<p>Within this first loop we’ll be keeping track of the post IDs being used. Nothing fancy is being done here. We’re just pulling the last five posts posted.</p>
<blockquote><p><code> </code></p>
<pre>&lt;?php
global $myPosts;
$myPosts = '';
?&gt;
&lt;div&gt;
&lt;?php
$my_query = new WP_Query();
$my_query-&gt;query('showposts=5');
if ($my_query-&gt;have_posts()) : while ($my_query-&gt;have_posts()) :
$my_query-&gt;the_post(); ?&gt;
&lt;?php $myPosts .= $post-&gt;ID . ","; ?&gt;
&lt;div&gt;&lt;?php the_title(); ?&gt;&lt;/div&gt;
&lt;!-- Post Stuff --&gt;
&lt;?php endwhile; endif; ?&gt;
&lt;/div&gt;</pre>
</blockquote>
<p>Pay special attention to the <strong>$myPosts</strong> variable, which is used to keep track of all of the post IDs.<span id="more-13"></span></p>
<h3>Step 3:  Add the Filter</h3>
<p>We’ll now need to add a <strong>posts_where</strong> filter for the second loop.  This filter will use the <strong>post_strip</strong> function we started in Step 1.</p>
<blockquote><p><code> </code></p>
<pre>&lt;?php add_filter('posts_where', 'post_strip'); ?&gt;</pre>
</blockquote>
<h3>Step 4:  Start the Second Loop</h3>
<p>The second loop is a repeat of the first loop to demonstrate that the posts are not being duplicated. The second loop uses a different loop technique since paging isn’t necessary.</p>
<blockquote><p><code> </code></p>
<pre>&lt;div&gt;
&lt;?php
$my_query = new WP_Query('showposts=5');
while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post();?&gt;
&lt;div&gt;&lt;?php the_title(); ?&gt;&lt;/div&gt;

&lt;!-- Post Stuff --&gt;

&lt;?php endwhile; ?&gt;
&lt;/div&gt;</pre>
</blockquote>
<h3>Step 5:  Remove the Filter</h3>
<p>The filter we added in Step 3 now needs to be removed.</p>
<blockquote><p><code> </code></p>
<pre>&lt;?php remove_filter('posts_where', 'post_strip'); ?&gt;</pre>
</blockquote>
<h3>Step 6:  Admire the Results</h3>
]]></content:encoded>
			<wfw:commentRss>http://hairtyson.com/how-to-avoid-duplicate-posts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
