I use a nested Term Query. When a post is not assigned to any term the Query will display all terms registered with the Taxonomy.
This only happens when no Term of any Taxonomy is selected.
Example:
I have two taxonomies: Location and Genre (only these two are assigned to my CPT, nothing else)
The Term Query displays terms of the Location taxonomy. When I don’t select any Term of both available taxonomies the Query will display all terms of the Location taxonomy. As soon as I select a Term of the Genre taxonomy the Query works and will be empty.
Step-by-step reproduction instructions:
Use a CPT and assign at least two custom taxonomies (TaxonomyA and TaxonomyB)
Create a Term Query inside a Post Query that calls your CPT
Set the nested Term Query to only include Post Terms of TaxonomyA
Create a CPT without selecting any Term
Your Term Query should now display all Terms registered with your TaxonomyA
unfortunately I don’t really understand these parameters so I can’t come to a conclusion myself just by looking at the developer resources.
If this indeed is intended behavior, would it be possible to modify the visibility conditions in a way to be able to hide the query in case the “default empty array” kicks in?
For example adding custom taxonomies to the visibility conditions so I could select: Show if > TaxonomyA > equal to > empty
Or something similar.
Because even if it is the default behavior it does not make it intuitive since it does not really make sense to display all terms when none are selected.
It makes sense in the context of a filter, in the sense that, you can show all results initially and allow a user to filter down those results by criteria.
I think it’s just two different models of thinking - one is starting with nothing and adding, and one is starting with everything and subtracting. There are valid use cases for both approaches.
To achieve what you want, you can potentially use a Visibility condition based on whether the url parameter of your filter is non-empty - that way you can hide the query if no filters have been selected. I haven’t tested this and it may cause the filters to not function if the Query is removed by the conditions, so needs to be tested.
ok, now I understand the logic behind this. Thanks for this explanation! In my case I don’t use any frontend filter though. I have a CPT where I want to display the Countries (Custom Taxonomy) that the post is assigned to. So when no country is selected the query should be empty.
As you can see in the screenshot of @Araminta I set up the query to include all Post Terms. That’s why I expect the query to be empty when no Post Terms are present.