I am trying to create a user controlled filter for this page: enlace oculto
The trouble I am running into is that I don’t have an option to add "Product Categories" to the Search & Pagination area.
I'm using a Taxonomy Filter to limit which products appear on the page and I’m selecting only 3 "Product Categories".
The results are great when the page first loads. Where I’m stuck is trying to allow users to further filter the products. I want them to be able to choose from those 3 product categories and update the results.
Is this possible? I feel like I’m missing something obvious.
Hi Marcus,
Thank you for contacting us and I'll be happy to assist.
To include a filter for "Product Categories", which visitors can change from the front-end, you can follow these steps:
1. Please open your view's edit screen and if you've added any fixed/static filter for product categories in the "Query Filter" section, please remove it.
( screenshot: enlace oculto )
2. Next, scroll to the "Search and Pagination" section and click the "New filter" button.
( screenshot: enlace oculto )
3. From the new popup window, select "Product categories" from the taxonomy filters section.
( screenshot: enlace oculto )
4. Select the type of front-end filtering field that you'd like to use for this, from the next screen and click "Insert shortcode" button.
( screenshot: enlace oculto )
5. This will add the shortcode for the front-end filter in the "Search and Pagination" section ( screenshot: enlace oculto ) and a connected dynamic query filter, in the "Query Filter" section ( screenshot: enlace oculto ).
6. As the last step, you can adjust the "Custom Search Settings" and the submit/reset buttons, as needed.
( screenshot: enlace oculto )
We also have a guide on the topic of search filters at:
https://toolset.com/documentation/getting-started-with-toolset/filter-content-lists-and-add-custom-search/
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
If I understand this correctly, then you are suggesting that I remove the filter that currently limits what is loaded on the page. The problem with that option is that I am then loading every single product on the page. What I want is to load only products from a few categories, then allow the user to further filter the page using those categories as the filter options.
It seems that this is not possible using Toolset, so I’ll explore other options. If you have any suggestions, please leave them here. Otherwise, I’ll close this ticket next time I’m on here.
Hi Marcus,
Thanks for writing back.
In your requirement, there are two challenges:
1. The front-end filters that visitors can interact with should be limited to only selective product categories.
This one is simple and you can add a checkbox type field for the product categories filtering (as explained in my last message) and hide the checkbox options through custom CSS code, which should not be available on the front-end.
2. The second part is that by default and with no filters when the page loads, it should only restrict the results to the specific product categories.
For this filtering, you can use "wpv_filter_query" filter along with "Taxonomy Parameters":
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
Here is an example snippet which should make its usage more clear:
https://toolset.com/forums/topic/excluding-a-taxonomy-from-a-view-using-a-filter-hook/#post-552238
For more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
regards,
Waqar
My issue is resolved now. Thank you!