From 6e12deb13bcb8ab0569f59aa8ea68f80eec1dd42 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sat, 27 Apr 2013 01:28:35 +0000 Subject: [PATCH] WP_Query: If the post_type QV is an array with only one element, don't treat it as a multiple post type query. If there is only one post type used by all taxonomies for a tax query, set the post type to the string. fixes #24204. git-svn-id: https://develop.svn.wordpress.org/trunk@24115 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 9d6307e688..441e5a84ca 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2237,6 +2237,8 @@ class WP_Query { } if ( ! $post_type ) $post_type = 'any'; + elseif ( count( $post_type ) == 1 ) + $post_type = $post_type[0]; $post_status_join = true; } elseif ( in_array('attachment', (array) $post_type) ) { @@ -2403,9 +2405,11 @@ class WP_Query { $orderby .= " {$q['order']}"; } - if ( is_array( $post_type ) ) { + if ( is_array( $post_type ) && count( $post_type ) > 1 ) { $post_type_cap = 'multiple_post_type'; } else { + if ( is_array( $post_type ) ) + $post_type = reset( $post_type ); $post_type_object = get_post_type_object( $post_type ); if ( empty( $post_type_object ) ) $post_type_cap = $post_type;