[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 2 08:11:35 UTC 2016


#35692: Allow seed value to be passed to WP_Query when using random ordering
-------------------------+-----------------------------
 Reporter:  hlashbrooke  |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Query        |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 When we build the MySQL query from the `WP_Query` class and `rand` is
 specified as the `orderby` argument in the query args, we parse the `ORDER
 BY` clause like this: `RAND()`. The parentheses there imply that a seed
 value could be passed to the `RAND` function, which would allow for
 consistent random ordering. This is a relatively common need when posts
 are ordered randomly, but need to retain persistent pagination.

 This can be worked around by using the `posts_orderby` filter of course,
 but it would be useful if we could simply specify a seed value in the
 query args that would be validated as an integer and then added to the
 `RAND()` function if it has been supplied.

 This would obviously be an entirely optional new argument, but it would
 make `WP_Query` just that much more powerful.

 [http://dev.mysql.com/doc/refman/5.0/en/mathematical-
 functions.html#function_rand Here are the docs] on the usage of a seed
 value for the `RAND()` function.

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


More information about the wp-trac mailing list