Ticket #38034: class-wp-query.diff
File class-wp-query.diff, 1.5 KB (added by , 8 years ago) |
---|
-
src/wp-includes/class-wp-query.php
1494 1494 $allowed_keys = array( 1495 1495 'post_name', 'post_author', 'post_date', 'post_title', 'post_modified', 1496 1496 'post_parent', 'post_type', 'name', 'author', 'date', 'title', 'modified', 1497 'parent', 'type', 'ID', 'menu_order', 'comment_count', 'rand', 1497 'parent', 'type', 'ID', 'menu_order', 'comment_count', 'rand', 'post__in', 1498 1498 ); 1499 1499 1500 1500 $primary_meta_key = ''; … … 1552 1552 case 'meta_value_num': 1553 1553 $orderby_clause = "{$primary_meta_query['alias']}.meta_value+0"; 1554 1554 break; 1555 case 'post__in': 1556 if( !empty( $this->query_vars['post__in'] ) ) { 1557 $orderby_clause = "FIELD({$this->db->posts}.ID," . implode( ',', array_map( 'absint', $this->query_vars['post__in'] ) ) . ")"; 1558 } 1559 break; 1555 1560 default: 1556 1561 if ( array_key_exists( $orderby, $meta_clauses ) ) { 1557 1562 // $orderby corresponds to a meta_query clause. … … 2143 2148 } 2144 2149 } elseif ( 'none' == $q['orderby'] ) { 2145 2150 $orderby = ''; 2146 } elseif ( $q['orderby'] == 'post__in' && ! empty( $post__in ) ) {2147 $orderby = "FIELD( {$this->db->posts}.ID, $post__in )";2148 2151 } elseif ( $q['orderby'] == 'post_parent__in' && ! empty( $post_parent__in ) ) { 2149 2152 $orderby = "FIELD( {$this->db->posts}.post_parent, $post_parent__in )"; 2150 2153 } elseif ( $q['orderby'] == 'post_name__in' && ! empty( $post_name__in ) ) {