[wp-trac] [WordPress Trac] #9300: WP_Query with posts_per_page and sticky posts

WordPress Trac noreply at wordpress.org
Mon Apr 29 08:28:36 UTC 2013


#9300: WP_Query with posts_per_page and sticky posts
------------------------------------+-----------------------------
 Reporter:  yukataninja             |       Owner:  anonymous
     Type:  defect (bug)            |      Status:  reopened
 Priority:  low                     |   Milestone:  Future Release
Component:  Query                   |     Version:  2.7
 Severity:  minor                   |  Resolution:
 Keywords:  dev-feedback has-patch  |
------------------------------------+-----------------------------
Changes (by JasonWoof):

 * keywords:  dev-feedback => dev-feedback has-patch


Comment:

 Here's a patch to fix this bug: http://jasonwoof.com/downloads/0001-Fix-
 pagination-with-sticky-posts-fixes-9300.patch

 I removed 48 lines of craziness (resorting the results of the query, and
 doing an additional query to get sticky posts that wouldn't otherwise be
 on the first page)

 I used the conditional that decides when there should be stickies at the
 top, and used it to add a sorting clause to the sql query so the sticky
 posts come at the beginning, and are paginated with the LIMIT clause as
 they should be.

 This is against WordPress 3.2.1. I hope it is useful for fixing the latest
 version too.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9300#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list