<?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>WP Garage &#187; exclude</title>
	<atom:link href="http://wpgarage.com/tag/exclude/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpgarage.com</link>
	<description>wordpress tricks, hacks, and tips</description>
	<lastBuildDate>Mon, 30 Aug 2010 10:34:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Display sticky post and exclude it from recent posts list in WordPress</title>
		<link>http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/</link>
		<comments>http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 13:30:03 +0000</pubDate>
		<dc:creator>Rebecca Markowitz</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[exclude]]></category>
		<category><![CDATA[recent posts]]></category>
		<category><![CDATA[sticky posts]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://wpgarage.com/?p=592</guid>
		<description><![CDATA[We were working on a WordPress site that needed to display a sticky post at the top of the blog page with one style, and then below it a list of the most recent posts with a completely different style. I realize that you can just style the sticky post using the sticky-related classes provided [...]]]></description>
			<content:encoded><![CDATA[<p>We were working on a WordPress site that needed to display a sticky post at the top of the blog page with one style, and then below it a list of the most recent posts with a completely different style.</p>
<p>I realize that you can just style the sticky post using the sticky-related classes provided by WordPress:</p>
<blockquote><p>&lt;div &lt;?php post_class(); ?&gt;&gt; and .sticky class</p></blockquote>
<p>but I needed to have design elements appear in between the sticky post and the rest of the recent posts, and the recent posts needed to have a completely different design than the sticky. Therefore I decided to go with a 2 loop solution. Once we were using two loops, we had to also make sure that sticky post did not repeat itself and appear in the list of recent posts following it.</p>
<p><a href="http://www.nathanrice.net/blog/definitive-sticky-posts-guide-for-wordpress-27/">Nathan Rice</a> provides a lot of useful information about sticky posts but I couldn&#8217;t get the code he posted to work properly. So I went on a hunt to figure it out.</p>
<h2>How to display a sticky post</h2>
<p>The best solution I found for how to display a WordPress sticky post was a <a href="http://justintadlock.com/archives/2009/03/28/get-the-latest-sticky-posts-in-wordpress#comment-113133">comment </a>by <cite title="http://www.ethymos.com.br"></cite><a title="Eduardo" rel="external nofollow" href="http://www.ethymos.com.br/">Eduardo</a> on Justin Tadlock&#8217;s post <a title="Get the latest sticky posts in WordPress" href="http://justintadlock.com/archives/2009/03/28/get-the-latest-sticky-posts-in-wordpress">Get the Latest Sticky Post</a>. He gave the following code:</p>
<blockquote><p>&lt;?php<br />
$sticky = get_option( &#8216;sticky_posts&#8217; );<br />
query_posts( array( &#8216;post__in&#8217; =&gt; $sticky, &#8216;caller_get_posts&#8217; =&gt; 1, &#8216;orderby&#8217; =&gt; ID, &#8216;showposts&#8217; =&gt; 2 ) );<br />
?&gt;<br />
&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;<br />
&lt;a href=&#8221;&lt;?php the_permalink(); ?&gt;&#8221; rel=&#8221;bookmark&#8221; title=&#8221;Permanent Link to &lt;?php the_title(); ?&gt;&#8221;&gt;<br />
&lt;?php endwhile;?&gt;</p>
<p>&lt;?php endif; ?&gt;</p></blockquote>
<p>It worked very nicely.</p>
<h2>How to exclude sticky posts from a list of recent posts</h2>
<p>I then wanted to show a list of 3 recent posts that excluded the post that had been defined as sticky. After many trials and errors with different solutions posted around the web, I finally found one that worked on the <a href="http://wordpress.org/support/topic/338776">WordPress Support Forum.</a></p>
<blockquote><p>&lt;?php $sticky = get_option(&#8216;sticky_posts&#8217;) ;</p>
<p>$post_to_exclude[] = $sticky[0];</p>
<p>$args=array(<br />
&#8216;caller_get_posts&#8217;=&gt;1,<br />
&#8216;showposts&#8217;=&gt;2,<br />
&#8216;post__not_in&#8217;=&gt; $post_to_exclude,<br />
);</p>
<p>query_posts($args); ?&gt;</p>
<p>&lt;h2&gt;&lt;a href=&#8221;&lt;?php the_permalink() ?&gt;&#8221;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt; &lt;/h2&gt;</p>
<p>&lt;?php while (have_posts()) : the_post();  ?&gt;</p>
<p>&lt;?php endwhile;?&gt;</p></blockquote>
<p>So there you have it: a workable way to have a WordPress sticky post with one style, and a list of recent posts excluding the sticky post with a completely different style below the sticky post.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress&amp;desc=We%20were%20working%20on%20a%20WordPress%20site%20that%20needed%20to%20display%20a%20sticky%20post%20at%20the%20top%20of%20the%20blog%20page%20with%20one%20style%2C%20and%20then%20below%20it%20a%20list%20of%20the%20most%20recent%20posts%20with%20a%20completely%20different%20style.%0D%0A%0D%0AI%20realize%20that%20you%20can%20just%20style%20the%20sticky%20post%20using%20the%20sticky-related%20classes%20provided%20by%20" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;t=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress&amp;link=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-gmail">
			<a href="https://mail.google.com/mail/?ui=2&amp;view=cm&amp;fs=1&amp;tf=1&amp;su=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress&amp;body=Link: http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A We%20were%20working%20on%20a%20WordPress%20site%20that%20needed%20to%20display%20a%20sticky%20post%20at%20the%20top%20of%20the%20blog%20page%20with%20one%20style%2C%20and%20then%20below%20it%20a%20list%20of%20the%20most%20recent%20posts%20with%20a%20completely%20different%20style.%0D%0A%0D%0AI%20realize%20that%20you%20can%20just%20style%20the%20sticky%20post%20using%20the%20sticky-related%20classes%20provided%20by%20" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.google.com/bookmarks/mark?op=add&amp;bkmk=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress&amp;srcUrl=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;srcTitle=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress&amp;snippet=We%20were%20working%20on%20a%20WordPress%20site%20that%20needed%20to%20display%20a%20sticky%20post%20at%20the%20top%20of%20the%20blog%20page%20with%20one%20style%2C%20and%20then%20below%20it%20a%20list%20of%20the%20most%20recent%20posts%20with%20a%20completely%20different%20style.%0D%0A%0D%0AI%20realize%20that%20you%20can%20just%20style%20the%20sticky%20post%20using%20the%20sticky-related%20classes%20provided%20by%20" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress&amp;summary=We%20were%20working%20on%20a%20WordPress%20site%20that%20needed%20to%20display%20a%20sticky%20post%20at%20the%20top%20of%20the%20blog%20page%20with%20one%20style%2C%20and%20then%20below%20it%20a%20list%20of%20the%20most%20recent%20posts%20with%20a%20completely%20different%20style.%0D%0A%0D%0AI%20realize%20that%20you%20can%20just%20style%20the%20sticky%20post%20using%20the%20sticky-related%20classes%20provided%20by%20&amp;source=WP Garage" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-netvibes">
			<a href="http://www.netvibes.com/share?title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress&amp;url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/" rel="nofollow" class="external" title="Submit this to Netvibes">Submit this to Netvibes</a>
		</li>
		<li class="shr-posterous">
			<a href="http://posterous.com/share?linkto=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress&amp;selection=We%20were%20working%20on%20a%20WordPress%20site%20that%20needed%20to%20display%20a%20sticky%20post%20at%20the%20top%20of%20the%20blog%20page%20with%20one%20style%2C%20and%20then%20below%20it%20a%20list%20of%20the%20most%20recent%20posts%20with%20a%20completely%20different%20style.%0D%0A%0D%0AI%20realize%20that%20you%20can%20just%20style%20the%20sticky%20post%20using%20the%20sticky-related%20classes%20provided%20by%20" rel="nofollow" class="external" title="Post this to Posterous">Post this to Posterous</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-sphinn">
			<a href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/" rel="nofollow" class="external" title="Sphinn this on Sphinn">Sphinn this on Sphinn</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/&amp;title=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-techmeme">
			<a href="http://twitter.com/home/?status=Tip+@Techmeme+http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/+&quot;Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress&quot;&amp;source=shareaholic" rel="nofollow" class="external" title="Tip this to TechMeme">Tip this to TechMeme</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fwpgarage.com%2Fcode-snippets%2Fdisplay-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress%2F&amp;t=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Display+sticky+post+and+exclude+it+from+recent+posts+list+in+WordPress+-++%28via+%40wpgarage%29&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-mail">
			<a href="mailto:?subject=%22Display%20sticky%20post%20and%20exclude%20it%20from%20recent%20posts%20list%20in%20WordPress%22&amp;body=Link: http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/ (sent via shareaholic)%0D%0A%0D%0A----%0D%0A We%20were%20working%20on%20a%20WordPress%20site%20that%20needed%20to%20display%20a%20sticky%20post%20at%20the%20top%20of%20the%20blog%20page%20with%20one%20style%2C%20and%20then%20below%20it%20a%20list%20of%20the%20most%20recent%20posts%20with%20a%20completely%20different%20style.%0D%0A%0D%0AI%20realize%20that%20you%20can%20just%20style%20the%20sticky%20post%20using%20the%20sticky-related%20classes%20provided%20by%20" rel="nofollow" class="external" title="Email this to a friend?">Email this to a friend?</a>
		</li>
		<li class="shr-printfriendly">
			<a href="http://www.printfriendly.com/print?url=http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/" rel="nofollow" class="external" title="Send this page to Print Friendly">Send this page to Print Friendly</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://wpgarage.com/code-snippets/display-sticky-post-and-exclude-it-from-recent-posts-list-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
