Tell us what you are trying to do?
I have a CPT called Bread and a CPT called Allergics.
I want to make a view with a filter through checkboxes. This view shows all the Bread posts.
The allergic Posts are shown with checkboxes. When I select pa. Nuts, now all the Breads which have nuts in them are shown.
I want it the other way around so by checking different boxes, the visitor can see which bread he or she can safely eat.
I guess I need a NOT statement instead of a OR statement.
Is there any documentation that you are following?
Been searching quiet some time in your documentation. Perhaps missed an article.
Hello,
Thanks for the details, there isn't such kind of built-in feature within Views plugin:
I want it the other way around so by checking different boxes, the visitor can see which bread he or she can safely eat.
It needs custom codes, here are my suggestions:
1) When user submit the search form, use wpv_filter_query to trigger a PHP function,
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
2) In this PHP function, do these:
- get the post ID values of URL parameter "Allergics"
- use above values to get related "bread" post IDs
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#wp_query-argument-for-querying-by-related-posts
- apply post IDs filter to query, exclude above specific "bread" post IDs
https://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters
post__not_in (array) - use post ids. Specify post NOT to retrieve. If this is used in the same query as post__in, it will be ignored