Wordpress - Broken? WP_Query and "attachment" as a post type
These are the query parameters i use...works for me when i loop through the results
array(
'post_parent' => $post->ID,
'post_status' => 'inherit',
'post_type'=> 'attachment',
'post_mime_type' => 'image/jpeg,image/gif,image/jpg,image/png'
);
Add in $args
, it is important.
'post_status' => 'any'
Do not: 'post_status' => null
This is important because attachments don't have a post_status
, so the default value for post_status
, published
, will find no attachments.