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

WordPress Trac wp-trac at lists.automattic.com
Sun Mar 8 06:22:26 GMT 2009


#9300: WP_Query with showposts and sticky posts
--------------------------+-------------------------------------------------
 Reporter:  yukataninja   |       Owner:  anonymous                      
     Type:  defect (bug)  |      Status:  new                            
 Priority:  normal        |   Milestone:  Unassigned                     
Component:  General       |     Version:                                 
 Severity:  normal        |    Keywords:  wp_query query showposts sticky
--------------------------+-------------------------------------------------
 When using WP_Query with showposts=some_number and you have one post set
 as a sticky that is out of the range of some_number, the query returned
 will have some_number plus one posts returned. If the sticky post is
 within the range of some_number then only some_number of posts is returned
 by WP_Query.

 '''Example Normal''': have 3 posts in order:
 Post 1,
 Post 2,
 Post 3

 my_WPQuery = new WP_Query("showposts=2");

 This will return Post 1 and Post 2

 '''Example Error''': have 3 posts in order:
 Post 1,
 Post 2,
 Post 3 (<-- make sticky)

 my_WPQuery = new WP_Query("showposts=2");

 This will return 3 posts (Post 3, Post 1, Post 2).

 ''Expected to return 2 posts (Post 3, Post 1).''

 '''Example OK''': have 3 posts in order:
 Post 1,
 Post 2 (<-- make sticky),
 Post 3

 my_WPQuery = new WP_Query("showposts=2");

 This will return 2 posts (Post 2, Post 1).

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


More information about the wp-trac mailing list