Tell us what you are trying to do? display results of filtering custom fields using OR parameter
Is there any documentation that you are following? No
Is there a similar example that we can see? No
What is the link to your site? Can provide privately
I have several custom fields in a post, and want to create a view with filters that the user can view results where the post has either of several results selected in a checkbox group. I am only able to get it to compare using AND, and there doesn't seem to be an OR option.
For example, I want to see all "students" who are EITHER "unenrolled" course ABC or only "partially completed" the same course. Currently results are often NILL because it's impossible that any student can be BOTH.
I cannot use taxonomies instead, because other custom fields are conditional upon the selection on the back end.
Is this possible?
(I can provide private a link to a password protected page with an example in a private message)
PS) I found a link to this support thread where I think the user had a similar issue, which makes me think its impossible, and the workaround suggested is beyond my skillset, so I am just wondering if there is now an easier option using the Toolset setup window? https://toolset.com/forums/topic/creating-a-multi-condition-andor-custom-filter-in-a-view/
Hi, after you insert your filter in the Search and Pagination section, you can modify the Query Filter for the checkboxes group custom field to use "in" instead of "equal to" (see the screenshot). If you cannot see the Query Filter panel, scroll to the top right corner of the screen and click "Screen Options" to expand the editor. You can turn the Query Filter panel on here.
Hi Christian,
Thanks so much for your response. This seems promising, but I think I maybe did a poor job of explaining my problem.
The filter I need is on the front end for the user to use. I need for them to be able to filter results using checkboxes where the results can be either of two scenarios( 'OR') — not both ('AND').
For example, if this is the checkboxes on the front end where the use has two options selected like this:
[ ✓ ] prospective students
[ ] newly enrolled students
[ ✓ ] students who have partially completed the course
[ ] students who have fully completed the course and graduated
I want the results to show both sets of people, both the prospective students and those who have partially completed the course. However, at the moment, the results in the above example would always produce zero reults, because it's impossible for a student to be both a prospective student and have also partially completed the course.
Attached is an image that shows the options I have available to me when I add the checkbox filter to the page.
Is what I want possible?
I need for them to be able to filter results using checkboxes where the results can be either of two scenarios( 'OR') — not both ('AND').
You explained it well, and that's exactly what happens when you choose "in" instead of "equal to" in the Query Filter. In your example, the "equal to" option filters results such that all the results shown have both "prospective" and "partially completed" checked. The "in" option will filter results such that all the results shown have either "prospective" or "partially completed" checked. Your screenshot shows the popup dialog for adding the checkboxes in the Search and Pagination editor. However, the "in" option isn't available in this popup, it's only available in the Query Filter editor area. So you can choose "equal to" when inserting the filter in the Search and Pagination editor, then scroll up to the Query Filter area and tweak the checkbox filter comparison to be "in" instead of "equal to".
Hi Christian ,
Thanks so much for persisting with me!
In that case, I think the problem I am having is that there is no Query Filter area when I scroll up within this View, and there doesn't seem to be a way for me to add one.
(I am used to using the Query Filter area when creating other types of view, but it's not available in this View.)
Would you like for me to provide access to take a look?
Katrina
If you cannot see the Query Filter panel, scroll to the top right corner of the screen and click "Screen Options" to expand the tab. You can turn the Query Filter panel on here.
Woah - thank you! The clouds have parted and now all makes more sense finally. Your solution works. Thank you so much, I really appreciate it!