When doing a taxonomy query, search against the currently registered post types of the queried taxonomies.
Prevents posts of a type no longer assigned to a queried taxonomy from being returned. props jondavidjohn. fixes #21290. git-svn-id: http://core.svn.wordpress.org/trunk@21855 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d91ae96dc9
commit
9ae3bf6fa6
|
@ -2220,7 +2220,16 @@ class WP_Query {
|
|||
|
||||
if ( $this->is_tax ) {
|
||||
if ( empty($post_type) ) {
|
||||
// Do a fully inclusive search for currently registered post types of queried taxonomies
|
||||
$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 ) ) )
|
||||
$post_type[] = $pt;
|
||||
}
|
||||
if ( ! $post_type )
|
||||
$post_type = 'any';
|
||||
|
||||
$post_status_join = true;
|
||||
} elseif ( in_array('attachment', (array) $post_type) ) {
|
||||
$post_status_join = true;
|
||||
|
|
Loading…
Reference in New Issue