From c5c65130c9760f44ea4236fb6c1804f32b02e2b5 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Thu, 6 Sep 2012 19:01:21 +0000 Subject: [PATCH] Allow orderby=post__in, which uses the explicit order you provided in the post__in parameter. fixes #13729. props jakemgold, Otto42. git-svn-id: https://develop.svn.wordpress.org/trunk@21776 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wp-includes/query.php b/wp-includes/query.php index 7d95230405..5c6897caa1 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2331,6 +2331,8 @@ class WP_Query { $orderby = "$wpdb->posts.post_date " . $q['order']; } elseif ( 'none' == $q['orderby'] ) { $orderby = ''; + } elseif ( $q['orderby'] == 'post__in' && ! empty( $post__in ) ) { + $orderby = "FIELD( {$wpdb->posts}.ID, $post__in )"; } else { // Used to filter values $allowed_keys = array('name', 'author', 'date', 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand', 'comment_count');