Opened 4 years ago
Closed 4 years ago
#11072 closed defect (bug) (fixed)
Honor Post Type for Sticky Posts
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9 |
| Component: | Query | Version: | |
| Severity: | normal | Keywords: | has-patch needs-testing |
| Cc: |
Description
When specifying a post type in WP_Query, sticky posts are added to the beginning of the array regardless of the post_type if specified. The attached patch will restrict the stickies to match the post_type if specified. This is compatible with the multiple post types patch submitted in #10791.
Attachments (1)
Change History (7)
chrisscott — 4 years ago
- Keywords changed from has-patch, needs-testing to has-patch needs-testing
This will break stickies for regular queries since the post_type is not set for them:
SELECT * FROM wp_posts WHERE wp_posts.ID IN (1611) AND wp_posts.post_type IN ('')
We'll need to set it further up or maybe use the post_type_cap.
prepare() doesn't get along with IN() queries. I think it'll be fine as is since post_type is sanitized.
Note: See
TracTickets for help on using
tickets.

The solution looks fine to me but I think the query should run to $wpdb->prepare first.