<?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 Engineer &#187; sticky</title>
	<atom:link href="http://wpengineer.com/tag/sticky/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Mon, 21 May 2012 22:48:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Strange Things With Sticky Posts</title>
		<link>http://wpengineer.com/293/strange-things-with-sticky-posts/</link>
		<comments>http://wpengineer.com/293/strange-things-with-sticky-posts/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 04:28:14 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[conditional tag]]></category>
		<category><![CDATA[sticky]]></category>
		<category><![CDATA[template tag]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.7]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=293</guid>
		<description><![CDATA[Frank wrote in one of his last posts about the new sticky functionality in WordPress 2.7. Right now I'm working on a special theme and I noticed some strange things with sticky posts. Wrong Post Count If you like to show 6 posts on a page, I use query_posts('showposts=6');. But if one or more posts [...]]]></description>
			<content:encoded><![CDATA[<p>Frank wrote in one of his last posts about the new <a href="http://wpengineer.com/sticky-function-in-wordpress-27/" title="sticky function in WordPress 2.7">sticky functionality</a> in WordPress 2.7. Right now I'm working on a special theme and I noticed some strange things with sticky posts.<br />
<span id="more-293"></span></p>
<h3>Wrong Post Count</h3>
<p>If you like to show 6 posts on a page, I use <code>query_posts('showposts=6');</code>. But if one or more posts are "sticky", they get added to the other 6 posts. To show 6 posts actually, you have to know how many sticky posts you have.</p>
<p><strong>The solution:</strong></p>
<p><code>get_option('sticky_post')</code> gives you an array back with sticky post ID, which we can count.</p>
<pre lang="php">
$sticky = count(get_option(&#039;sticky_posts&#039;));
query_posts(&#039;showposts=&#039;. ( 6 - $sticky ));
</pre>
<h3>Still showing sticky posts in chronological sort order</h3>
<p>Pay attention to the CSS classes of the posts. The template tag <code>post_class()</code> gives the post the class. In the case of sticky post, it is also the class "sticky". If you think you can give the class sticky a red background and black border to have a nice teaser you will be disappointed. If you go to the next page to see previous posts, the sticky post will also be showed in the chronological order with a red background and black borders. Not really cool.</p>
<h3>Kill the Sticky</h3>
<p>If you don't want to have sticky posts, just write in your template:</p>
<pre lang="php">
update_option(&#039;sticky_posts&#039;, array());
</pre>
<p>With the empty array you overwrite the sticky options and no sticky posts are availably.</p>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/293/strange-things-with-sticky-posts/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

