[wp-trac] [WordPress Trac] #35692: Allow seed value to be passed to WP_Query when using random ordering

WordPress Trac noreply at wordpress.org
Tue Feb 23 16:39:52 UTC 2016


#35692: Allow seed value to be passed to WP_Query when using random ordering
-------------------------+---------------------------
 Reporter:  hlashbrooke  |       Owner:  boonebgorges
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:  4.5
Component:  Query        |     Version:  trunk
 Severity:  normal       |  Resolution:  fixed
 Keywords:  has-patch    |     Focuses:
-------------------------+---------------------------
Changes (by boonebgorges):

 * owner:   => boonebgorges
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"36632"]:
 {{{
 #!CommitTicketReference repository="" revision="36632"
 Query: Allow a seed value to be passed when using 'rand' `$orderby`.

 `WP_Query` allows random ordering; `'orderby' => 'rand'` translates to
 `ORDER BY RAND()`. This syntax results in random ordering that is not
 consistent from request to request. MySQL supports the passing of a seed
 value
 to random sorts, such as `ORDER BY RAND(3)`, which will return the same
 random value each time it's called. `WP_Query` now supports this syntax,
 by
 passing `RAND(3)` (or whatever integer seed value you'd like) as the value
 of `'orderby'`.

 Props hlashbrooke.
 Fixes #35692.
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35692#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list