[wp-hackers] Sticky posts and Posts Per Page

Jake Goldman wphackers at jakemgold.myfastmail.com
Tue Aug 3 16:42:14 UTC 2010


  Anyone know of an "elegant" solution for getting sticky posts to count 
toward the posts per page limit?

The use case here is a /very /formatted 3x3 grid output for posts. The 
client wants to be able to use sticky posts to feature his best work, 
but it can't break the 3x3 grid. Out of the box, sticky posts get added 
on top of the posts per page count.

Keep in mind that there are dozens of posts already - so paging is 
important. I can't simply count up the sticky posts and subtract from 
posts per page (setting a new posts_per_page) without breaking paging.

Using count of stickies - posts_per_page for page 1 and then using an 
offset on subsequent pages would work if I could have a negative offset 
(which it seems I can't). It gets even more complicated if the there are 
more sticky posts than there are post blocks on the first page (9), but 
I can impose rules to limit the site to a maximum of 9 sticky posts.

I have a few hack-ish ideas, but I thought I'd pose the question first 
in case anyone has dealt with this limitation before.

Jake


More information about the wp-hackers mailing list