Tell us what you are trying to do?
Hi, I'm tryin to set up a 'quiz' using a search form. I'd like the user to answer a number of questions, and get the results for each question. I'm sure it must have something to do with the AND/OR operators, but I can't quite work it out.
At the moment, if you choose one filter you get the desired result, but when you choose multiple you get no results.
Is there any documentation that you are following?
no
Is there a similar example that we can see?
I've started setting it up on the link below
What is the link to your site?
hidden link
Hello and thank you for contacting the Toolset support.
I am not really sure to understand what you want to build. Can you elaborate more? Maybe give a detailed example(when the following values are entered, the following results should be returned)?
What do you mean by results? A score or a set of posts that match the user input?
Thank you for your reply, sorry I wasn't clearer.
I have made a custom post type, called 'Quiz Answers', plus a series of custom taxonomies, which relate to the 'questions'.
For example, one taxonomy is called 'Time', and one is called 'Skills'.
In the 'Time' taxonomy, there are 3 categories:
- 1 hour
- 2 hours
- 3 hours
In the 'Skills' taxonomy there are 3 categories:
- Creative
- Financial
- Organizer
The search form would then have select boxes for each taxonomy, which would be framed as 'questions'
eg: How much time do you have?
- 1 hour
- 2 hours
- 3 hours
What are your skills?
- Creative
- Financial
- Organizer
If the user selects '2 hours' and 'creative' I would like all the posts categorized with '2 hours' or 'creative' to be displayed.
Does that make sense?
Thank you for the example, I understand better your request.
From what I gathered so far, you have correctly set the view's search form on a page, and the view's results on another page. I can get results when selecting one filter, and no results when selecting another.
I'll suggest activating the view's debug in Toolset->Settings->Front-end Content to get more details about the query arguments and the underlying SQL query. Maybe you can spot what is going on.
To better assist you further, I'll need to take a closer look as an admin. It would also help me if you give an example, or a test case(these search filters should return these posts) to investigate what's going on. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
Thank you for your feedback.
First, the view was not having any query filters. Check this screenshot hidden link
I recreated the filters to generate the corresponding query filters, but that did not help.
For some reason, the relation between taxonomies was AND instead of OR. I suspect that another component(theme or plugin) is altering it. So, I added a custom code to Toolset->Settings->Custom Code section, which enforces the 'OR' operator on the query instead of the 'AND'. And now, I am getting 2 posts for the test case. Check this screenshot hidden link
I hope this helps. Let me know if you have any questions.
Thanks Jamal! That works great. One last question - how do I remove the debug screen?
Sorry for missing this last question. You can remove it from Toolset->Settings->Front-end Content(tab). Read more about it here https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/#the-views-debug-tool