I am trying to add a filter to my View that excludes one category, but the filter UI doesn't include an option to add an 'operator' such as 'NOT IN'. I've seen screenshots in the help docs and other support threads that include filters like this, but maybe it was an old version? Should those options still be there? How would I accomplish this otherwise?
Thank you.
Dear dave,
You are right, there isn't such an option in taxonomy view.
But you can try with Views filter hook "wpv_filter_taxonomy_query", to add the filter you want:
https://toolset.com/documentation/user-guides/views-filters/wpv_filter_taxonomy_query/
When displaying a View listing taxonomy terms, this filter is applied to the arguments that will be passed to the get_terms() call.
To add the "exclude" parameters:
https://developer.wordpress.org/reference/functions/get_terms/
'exclude'
(array|string) Array or comma/space-separated string of term ids to exclude. If $include is non-empty, $exclude is ignored.
Hi Luo,
Thanks for your reply! I noticed on the link you sent that that filter is being reworked and will probably change in the near future. Is there any other solution that would work so that this does not break when you guys change this filter? Are there plans to add a "NOT IN" operator to the Views filters anytime soon?
Thanks,
Dave
Q1) Is there any other solution that would work so that this does not break when you guys change this filter?
No, I don't think there is other better solution, if we change this filter, we will provide you a way to upgrade this filter
Q2) Are there plans to add a "NOT IN" operator to the Views filters anytime soon?
No, there isn't plans for it, if you agree, we can take it as a feature request
Thanks. I'll take my chances with that filter and see how it goes. Thanks again!