How To Query For An Empty Taxonomy Field
Question
I want to write a query that looks up taxonomies. One condition is that taxonomyA returns x, and a second condition is that taxonomyB returns empty. I don’t know how to query for empty.
This is what I have:
$args = [
'post_type' => 'post',
'tax_query' => [
'relation' => 'AND',
[
'taxonomy' => 'areaoflondon',
'field' => 'name',
'terms' => 'South London',
'include_children' => false,
],
[
'taxonomy' => 'yearofvisit',
'field' => 'name',
'terms' => '',
'include_children' => false,
]
],
'posts_per_page' => 5,
'meta_key' => 'rating',
'meta_type' => 'NUMERIC',
'order' => 'DESC',
'orderby' => 'meta_value_num',
];
However this doesn’t return any results.
How can I query that a taxonomy is empty? Is it even possible?
Thanks
James
0
1 year
2022-02-20T04:57:28-05:00
2022-02-20T04:57:28-05:00 0 Answers
0 views
0
Leave an answer