要从同一术语中获取所有图像,可以使用WP\\u Query和“tax\\u Query”参数:
$args = array(
\'post_status\' => \'inherit\',
\'posts_per_page\' => -1,
\'post_type\' => \'attachment\',
);
$args[\'tax_query\'] = array(
array(
\'taxonomy\' => \'YOUR_CUSTOM_TAXONOMY\',
\'terms\' => array( \'YOUR_CUSTOM_TAXONOMY_TERM\' ),
\'field\' => \'slug\',
),
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
// DO SOMETHING
}
}
/* Restore original Post Data */
wp_reset_postdata();