Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#36720 closed defect (bug) (duplicate)

WP_Query should not return more than "posts_per_page" if ignore_sticky_posts is not set

Reported by: bastho's profile bastho Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.5
Component: Query Keywords:
Focuses: Cc:

Description

Case seen on a website containing 2849 posts where 2479 are sticky.

calling from the home page:

<?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
$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.

Change History (3)

#1 @bastho
9 years ago

  • Summary changed from WP_Query should'nt return more than "posts_per_page" is ignore_sticky_posts is nont set to WP_Query should'nt return more than "posts_per_page" if ignore_sticky_posts is nont set

#2 @swissspidy
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Summary changed from WP_Query should'nt return more than "posts_per_page" if ignore_sticky_posts is nont set to WP_Query should not return more than "posts_per_page" if ignore_sticky_posts is not set

Hey there,

Thanks for your report! Looks like this is already being tracked in #27282.

#3 @bastho
9 years ago

Thank you.
I could not find the original

Note: See TracTickets for help on using tickets.