Mend Sticky Posts

WordPress's Sticky Posts behaviour is still incomprehensible, let's fix it.

Author:Martin Shopland (profile at wordpress.org)
WordPress version required:3.0.1
WordPress version tested:3.4.2
Plugin version:1.1
Added to WordPress repository:24-09-2012
Last updated:25-09-2012
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:100
Rated by:1
Plugin URI:http://www.redbrickstudios.co.uk
Total downloads:1 146
Active installs:10+
plugin download
Click to start download
  • Sticky posts are ordered the same way as non-sticky posts.
  • Sticky posts do not reappear on subsequent pages.
  • The first page of home will contain exactly the requested number of posts, rather than the requested number of posts plus the number of sticky posts.
  • Allows more than one page of sticky posts.

Simply injects the sticky post IDs into the actual mySQL order by clause, causing posts to be ordered by sticky status then by what ever order is specified, usually post_date DESC, and not to repeat on subsequent pages. I can't actually figure out why it isn't done like this by WP, perhaps earlier versions of mySQL don't support this. WP's default sticky ordering craziness is turned off by returning an empty array for the next call to get_option('sticky_posts') which happens in WP_Query->get_posts().

There is currently a ticket awaiting review on the WordPress trac system to roll this functionality into the WordPress core: http://core.trac.wordpress.org/ticket/21986