My category field got 50 categories but I only want to show 5-10 (that I have selected) in the search bar.
Is this possible?
Hello there,
Thank you for contacting the Toolset support forum!
This will require some code customization, I’m afraid. Unfortunately, even if you add a static query filter for the taxonomy through the "Content Selection -> Query Filter" section, it would be overridden by the dynamic query applied by the front-end search field for that same taxonomy.
Therefore, to achieve what you're planning, you'll need to take care of two things:
1. You can hide the unwanted category term options from the front-end filter using custom CSS code, so that the user can't select them (it would be simpler if you use the select/drop-down type filter)
2. To dynamically apply a static query filter for the selected categories, only when a user has not selected it from the front-end. You can remove it from "Content Selection -> Query Filter" section and instead apply it through the "wpv_filter_query" filter:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
We have a relevant usage example for this, please check it out: https://toolset.com/forums/topic/custom-taxonomy-dynamically-choose-all-filter/#post-1617211
Please let me know if you need any further assistance around this. Thanks!
Regards,
Mateus.
Okay great and can you tell me what CSS code I can use to hide the category 'Binnenplaats' and 'Drinkwater'
Hi there,
Thanks for your reply.
We can give it a try, but please bear in mind that custom code solutions are beyond the scope of this support forum, and generally what we recommend is that you check our contractors page: https://wpml.org/contractors/.
Could you please show us where in the website we can see those categories in a search box? We tried to search for them, but since the website is in Dutch, we weren’t able to find anything.
Please keep us posted. Thank you.
My issue is resolved now. Thank you!