I’ve searched high and low, but haven’t found the exact code to do this.
I want to show all posts of a that don’t have a custom taxonomy assigned.
So something like, pull all posts that have one of the custom taxonomy, then show everything but those posts.
If you use
WP_Query
‘stax_query
, you can set theoperator
toNOT IN
and then just list your terms. The best way to do this (IMO) is to generate the tax query separately and dynamically, since all that will be changing in each of the different arguments is the slug/id of the category name. Your code should look something like this:Note: I wrote this straight into the editor, it’s totally untested and is more pseudocode than actual code. You will need to provide your own array for
$array_of_terms
, that’s simple stuff though.Once you’ve got that, you can just set
'tax_query' => $tax_query
as one of yourWP_Query
args.