[wp-trac] [WordPress Trac] #48020: Queries display in inconsistent order when ordering by meta_value_num

WordPress Trac noreply at wordpress.org
Wed Sep 11 17:00:10 UTC 2019


#48020: Queries display in inconsistent order when ordering by meta_value_num
--------------------------+-----------------------------
 Reporter:  truheart      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48020>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list