您需要首先抓取帖子,然后抓取作为所述帖子子级的附件。
$my_query = new WP_Query( array(
\'meta_key\' => \'my_hash\',
\'nopaging\' => true,
\'orderby\' => \'meta_value\',
\'fields\' => \'ids\',
\'cat\' => \'60\',
));
if ( $post_ids = $my_query->get_posts() ) {
$post_ids = implode( \',\', $post_ids );
$atts_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_parent IN($post_ids) AND post_type = \'attachment\'" );
$my_query->query( array(
\'posts_per_page\' => $batch_size,
\'post_mime_type\' =>\'image\',
\'post_status\' => \'all\',
\'post_type\' => \'attachment\',
\'post__in\' => $atts_ids,
));
}