From fa10ccba23e19ab321130c9a90bbfcc044d54999 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 20 Nov 2012 17:33:21 +0000 Subject: [PATCH] Account for taxonomies tied to specific kinds of attachments when setting up post types for a taxonomy query. props jondavidjohn. see #21290. git-svn-id: http://core.svn.wordpress.org/trunk@22718 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index d4e1b5a441..443d0bb742 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2224,7 +2224,8 @@ class WP_Query { $post_type = array(); $taxonomies = wp_list_pluck( $this->tax_query->queries, 'taxonomy' ); foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) { - if ( array_intersect( $taxonomies, get_object_taxonomies( $pt ) ) ) + $object_taxonomies = $pt === 'attachment' ? get_taxonomies_for_attachments() : get_object_taxonomies( $pt ); + if ( array_intersect( $taxonomies, $object_taxonomies ) ) $post_type[] = $pt; } if ( ! $post_type )