[wp-hackers] Taxonomy query returns posts when term does not exist

Peter Adams peter at oncefuture.com
Sun Feb 19 12:11:25 UTC 2012

Is there are way to stop WP_query from returning posts when the term used in the 'tax_query' portion of the query does not exist? 

I'm querying against the slug field of multiple taxonomies. All works as expected when the term exists in any of the taxonomies. However, when the term used does not exist, WP_query omits the tax_query and continues to return the latest 10 posts.

I have wrap the query in a "if ( term_exists('someterm') )..."  to avoid this from happening but am hoping there is a better way.



More information about the wp-hackers mailing list