diff --git a/wp-includes/query.php b/wp-includes/query.php index 988787a96e..e304bdefaf 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1468,6 +1468,7 @@ class WP_Query { * @since 4.5.0 Removed the `$comments_popup` parameter. * Introduced the `$comment_status` and `$ping_status` parameters. * Introduced `RAND(x)` syntax for `$orderby`, which allows an integer seed value to random sorts. + * @since 4.6.0 Added 'post_name__in' support for `$orderby`. * @access public * * @param string|array $query { @@ -1523,7 +1524,8 @@ class WP_Query { * 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand', * 'RAND(x)' (where 'x' is an integer seed value), * 'comment_count', 'meta_value', 'meta_value_num', 'post__in', - * and the array keys of `$meta_query`. + * 'post_name__in', 'post_parent__in', and the array keys + * of `$meta_query`. * @type int $p Post ID. * @type int $page Show the number of posts that would show up on page X of a * static front page. @@ -2745,7 +2747,8 @@ class WP_Query { $where .= " AND $wpdb->posts.post_name = '" . $q['attachment'] . "'"; } elseif ( is_array( $q['post_name__in'] ) && ! empty( $q['post_name__in'] ) ) { $q['post_name__in'] = array_map( 'sanitize_title_for_query', $q['post_name__in'] ); - $where .= " AND $wpdb->posts.post_name IN ('" . implode( "' ,'", $q['post_name__in'] ) . "')"; + $post_name__in = "'" . implode( "','", $q['post_name__in'] ) . "'"; + $where .= " AND $wpdb->posts.post_name IN ($post_name__in)"; } // If an attachment is requested by number, let it supersede any post number. @@ -2963,6 +2966,8 @@ class WP_Query { $orderby = "FIELD( {$wpdb->posts}.ID, $post__in )"; } elseif ( $q['orderby'] == 'post_parent__in' && ! empty( $post_parent__in ) ) { $orderby = "FIELD( {$wpdb->posts}.post_parent, $post_parent__in )"; + } elseif ( $q['orderby'] == 'post_name__in' && ! empty( $post_name__in ) ) { + $orderby = "FIELD( {$wpdb->posts}.post_name, $post_name__in )"; } else { $orderby_array = array(); if ( is_array( $q['orderby'] ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 8e509ac740..f31a816424 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-alpha-37224'; +$wp_version = '4.6-alpha-37225'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.