[wp-trac] [WordPress Trac] #36720: WP_Query should'nt return more than "posts_per_page" is ignore_sticky_posts is nont set

WordPress Trac noreply at wordpress.org
Fri Apr 29 12:28:12 UTC 2016


#36720: WP_Query should'nt return more than "posts_per_page" is ignore_sticky_posts
is nont set
--------------------------+-----------------------------
 Reporter:  bastho        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  4.5
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 Case seen on a website containing 2849 posts where 2479 are sticky.

 calling from the home page:
 {{{#!php
 <?php
 $query = new WP_Query(array (
     'order' => 'DESC',
     'orderby' => 'post_date',
     'post_type' => 'post',
     'posts_per_page' => '4',
     'posts_type' => 'post',
     'post__not_in' =>
     array (
     ),
   ));
 }}}
 returns 2479 posts while:
 {{{#!php
 <?php
 $query = new WP_Query(array (
     'order' => 'DESC',
     'orderby' => 'post_date',
     'post_type' => 'post',
     'posts_per_page' => '4',
     'posts_type' => 'post',
     'ignore_sticky_posts'=>1
     'post__not_in' =>
     array (
     ),
   ));
 }}}
 returns only 4 posts.

 For an unknown reason, the limit is not applied on stickies.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36720>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list