mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-04 04:34:31 +00:00
Ordering by RAND():
The shortcode callbacks for `gallery` and `playlist` check for `'RAND' == $atts['order']`, which isn't a valid value for `order`. Remove those checks and update the docs. In `WP_Query`, if the value of `orderby` is `rand`, `order` is irrelevant and should be unset. Adds unit tests. Fixes #29629. git-svn-id: https://develop.svn.wordpress.org/trunk@29760 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2795,10 +2795,11 @@ class WP_Query {
|
||||
|
||||
$where .= $search . $whichauthor . $whichmimetype;
|
||||
|
||||
$rand = ( isset( $q['orderby'] ) && 'rand' === $q['orderby'] );
|
||||
if ( ! isset( $q['order'] ) ) {
|
||||
$q['order'] = 'DESC';
|
||||
$q['order'] = $rand ? '' : 'DESC';
|
||||
} else {
|
||||
$q['order'] = $this->parse_order( $q['order'] );
|
||||
$q['order'] = $rand ? '' : $this->parse_order( $q['order'] );
|
||||
}
|
||||
|
||||
// Order by.
|
||||
@@ -2849,8 +2850,8 @@ class WP_Query {
|
||||
$orderby = implode( ' ' . $q['order'] . ', ', $orderby_array );
|
||||
|
||||
if ( empty( $orderby ) ) {
|
||||
$orderby = "$wpdb->posts.post_date ".$q['order'];
|
||||
} else {
|
||||
$orderby = "$wpdb->posts.post_date " . $q['order'];
|
||||
} elseif ( ! empty( $q['order'] ) ) {
|
||||
$orderby .= " {$q['order']}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user