我关注了两篇与我的问题相关的帖子。一个是关于number of images attached to a post 第二,关于showing all images of a certain post type. 我试图以以下方式将这两个代码组合在一起,但无济于事:
$query = new WP_Query( array( \'post_type\' => \'gallery\', \'posts_per_page\' => -1 ) );
if( $query->have_posts() ){
while($query->have_posts()){
$query->the_post();
$attachments = get_children( array( \'post_parent\' => $parent->ID, \'post_status\' => \'inherit\', \'post_type\' => \'attachment\', \'post_mime_type\' => \'image\', \'order\' => \'ASC\', \'orderby\' => \'menu_order ID\' ) );
$count = count( $attachments );
}
}
有谁能帮我计算某个帖子类型所附的所有图片吗?