samedi 31 janvier 2015

How to do a query on custom taxonomies that is uncategorised?


I have a custom taxonomy and I wish to do a query for all custom posts who has no value assigned for that taxonomy (i.e. uncategorised).


This is what I have so far:



$uncatQuery = new WP_Query( array(
'post_type' => 'course',
'tax_query' => array (
array(
'taxonomy' => 'course_category',
'field' => 'name',
'terms' => '',
)
)
) );


However this does not work.


Please help!


NOTE: I manage to get it to work by creating a query to get all tax ids and then use a NOT IN operator, but that requires an additional query.





Aucun commentaire:

Enregistrer un commentaire