私は 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 );
データベースに関しては、クエリなしですべての投稿を非常に簡単に取得できるため、これはばかげたクエリのように思えます。