WordPress.org

Make WordPress Core

Opened 7 weeks ago

Last modified 7 weeks ago

#48020 new defect (bug)

Queries display in inconsistent order when ordering by meta_value_num

Reported by: truheart Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:
PR Number:

Description

So I caught this the other day. When ordering a query by
meta_value_num, multiple posts sharing the same meta value display in a random order such that if you run two identical queries, the order of the posts could differ between the two.

Example use case. I have a custom class post type with a date post meta. Many classes share the same date. On the frontend, I am displaying 12 classes at a time, ordered by date, and when users select to load more I fetch more posts from the server with and query more classes with
'offset' => $classes_showing and 'orderby' => 'meta_value_num'. Classes belonging to the same show up in different orders from query to query, which occasionally results in multiple classes shown on the frontend.

Hopefully that was clear enough. Let me know if you need more code. Thanks.

Change History (1)

#1 @davidbaumwald
7 weeks ago

  • Component changed from General to Query
Note: See TracTickets for help on using tickets.