﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
22556,A taxonomy archive query for attachments can't return results,ocean90,,"In #21391 we made it easier to use custom taxonomies for attachments.

Example:
{{{
function ds_register_attachment_taxonomies() {
	$args = array(
		'label' => 'Color',
	);

	register_taxonomy(
		'image-color',
		'attachment:image',
		$args
	);
}
add_action( 'init', 'ds_register_attachment_taxonomies' );
}}}

This makes it also possible to make a query for this specific taxonomy. Example: 5 images has the term ""red"". The query: !http://example.com/image-color/red/

But: The page returns no attachments.

The query:
{{{
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (404) ) AND wp_posts.post_type IN ('attachment') AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 1
}}}

The problem is the `AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')` part. Attachments post status is inherit, therefore no results.

The attached patch checks if the current post type is `attachment` and sets the post_status to `inherit`.

I would like to get this in 3.5, since it's one of the new features and could be really annoying,
",defect (bug),new,normal,Future Release,Query,3.5,normal,,3.6-early,jeff@…
