I am trying to create a view that shows only one category with a checkbox that when checked shows one additional one together with the first. The CPT has more than those two categories, but I want only those two to show.
In addition, I would like to have a text search that searches only in the first category or both respectively.
I have tried several approaches, but have not been able to figure it out.
Can you please point me in the right direction?
Truls
Hello and thank you for contacting the Toolset support.
I assume that you want to have a dropdown to select the first category, and a check box to display another dropdown to select a second category, right? If yes, it can't be implemented without some custom code. Toolset, by default, offers only one control for each filter. I will not render two select fields for the same taxonomy filter(categories).
On the first hand, Toolset does not have a built-in feature to toggle a filter based on a checkbox. You will require custom code to implement such a feature.
On the second hand, you will also need custom Javascript code in order to generate a second dropdown with the possible categories except the first one selected.
I would suggest a different approach. But, it will still require some custom code, at least to remove the first selected category from the second dropdown. I would suggest using a secondary taxonomy, and a 3rd party plugin to copy the categories to this new taxonomy. Then, have two taxonomy filters on the view, the first for categories, and the second for the newly created taxonomy.
For better user experience, custom Javascript code will be required to implement features such as: Disabling the second filter until the first one has a value, removing the first category from the second filter when selected.
I hope this helps. Let me know if you have any questions.