您可以使用tax query 对于所有“引用类型”术语,将检索至少有一个“引用类型”术语的所有附件。
$rt_media = new WP_Query(
array(
\'posts_per_page\' => -1,
\'post_type\' => \'attachment\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'reference_type\',
\'terms\' => get_terms(
\'reference_type\',
array(
\'hide_empty\' => false,
\'fields\' => \'ids\',
)
)
)
)
)
);
while ( $rt_media->have_posts() ) : $rt_media->the_post(); ?>
<div class="item">
Use any template tags you want to output the list!
</div>
<?php endwhile ?>