听起来你想has_term()
. 类似于:为查询提供一个术语数组:
$args = array(
\'post_type\' => \'exhibitions\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'exhibition\',
\'field\' => \'slug\',
\'terms\' => array(
\'current\',
\'upcoming\',
),
),
)
);
$query = new WP_Query($args);
然后在其上循环多次:
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
if (has_term(\'current\',\'exhibition\')) {
// stuff
}
}
}
$query->rewind_posts();
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
if (has_term(\'upcoming\',\'exhibition\')) {
// stuff
}
}
}
$query->rewind_posts();