WordPress.org

Make WordPress Core

#25815 closed defect (bug) (invalid)

Sticky Posts don't work with category__in query

Reported by: thezuberat Owned by:
Milestone: Priority: normal
Severity: major Version:
Component: Query Keywords: stickies
Focuses: Cc:

Description (last modified by johnbillion)

If the category__in argument is used for the query (query_posts(), etc.) the sticky posts do not work anymore. See:

This is imo a major issue because you can't create category specific queries which support sticky posts atm.

Change History (4)

comment:1 @johnbillion18 months ago

  • Description modified (diff)

comment:2 @SergeyBiryukov18 months ago

  • Component changed from General to Query

comment:3 @wonderboymusic18 months ago

  • Keywords stickies added

comment:4 @wonderboymusic15 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Any tax_query-like thing negates is_home(), which is never true when is_archive() is true, which is true because is_category() is true. Your best bet is to display sticky-by-category posts in your template using a subquery:

new WP_Query( array( 'post__in' => get_option( 'sticky_posts' ), 'category__in => .... )

Note: See TracTickets for help on using tickets.