Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#11072 closed defect (bug) (fixed)

Honor Post Type for Sticky Posts

Reported by: chrisscott's profile chrisscott Owned by: ryan's profile ryan
Milestone: 2.9 Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch needs-testing
Focuses: 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)

query.php.diff (1.1 KB) - added by chrisscott 15 years ago.

Download all attachments as: .zip

Change History (7)

#1 @scribu
15 years ago

  • Milestone changed from Unassigned to 2.9

#2 @scribu
15 years ago

  • Keywords changed from has-patch, needs-testing to has-patch needs-testing

#3 @tott
15 years ago

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

#4 @ryan
15 years ago

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.

#5 @ryan
15 years ago

prepare() doesn't get along with IN() queries. I think it'll be fine as is since post_type is sanitized.

#6 @ryan
15 years ago

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

[12143]

I added an empty string check to get it working.

Note: See TracTickets for help on using tickets.