我正在编写一个 wordpress 循环,我想获取所有没有分配任何术语的帖子。有没有简单的方法来做到这一点?还是我真的必须获取所有术语 ID 并进行如下税务查询:
// Get all the term id's
$terms = array();
$terms = getAllTheTerms();
// Create an arguments which get all the posts that do not have a term with any
// of the id's.
$args = array(
'post_type' => 'post',
'tax_query' =>
array(
'taxonomy' => 'actor',
'field' => 'id',
'terms' => $terms,
'operator' => 'NOT IN'
)
);
$query = new WP_Query( $args );
这似乎是一个愚蠢的查询,因为就数据库而言,无需查询即可轻松获取所有帖子。