Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#11197 closed defect (bug) (fixed)

WP_Query post__not_in parameter ignored for sticky posts

Reported by: tidywebdev Owned by:
Milestone: 3.0 Priority: low
Severity: minor Version: 2.9.2
Component: General Keywords: sticky WP_Query
Focuses: Cc:


If you specify an array of post IDs for the postnot_in parameter when doing a custom query using a WP_Query object, the posts will still be returned if they are sticky.

The only way to avoid this is to also include the caller_get_posts=1 parameter, which stops the sticky posts appearing at the top of the post list, thus losing some of the sticky functionality.

Change History (5)

#1 @scribu
6 years ago

  • Milestone changed from Unassigned to 2.9
  • Resolution set to fixed
  • Status changed from new to closed

This seems to have been fixed in 2.9.

#2 @itxitx
5 years ago

  • Cc itxitx added
  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Version changed from 2.8.6 to 2.9.2

not fixed in wp 2.9.2

the behavior is:
if we have some sticky posts then set post__not_in parameter with one or two or more sticky post ID, instead excluding them from posts, it only changes the order of sticky posts.

#3 @dd32
5 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [14217]) Ignore sticky posts which the current user cannot read, Ignore sticky posts which have been explicitly excluded with 'postnot_in'. Fixes #11197

#4 @dd32
5 years ago

  • Milestone changed from 2.9 to 3.0

#5 @ryan
5 years ago

(In [14245]) The read_post cap cannot be checked for sticky posts because not logged in users don't have any caps. see #11197

Note: See TracTickets for help on using tickets.