Home › Toolset Professional Support › [Resolved] Hide empty filters
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Karachi (GMT+05:00)
Tagged: Custom search, Views, Views plugin
Related documentation:
This topic contains 3 replies, has 2 voices.
Last updated by romanB-3 4 years, 7 months ago.
Assisted by: Waqar.
Hi,
Thanks to Jamal, I was able to hide empty filters
https://toolset.com/forums/topic/hide-empty-filters/
But now the code don't work anymore, and I can't see why would that be!
I doubled check the #id is stille there, and the code didn't move either...
Thank you.
Here is an example : hidden link
The filter "Publications" should have disappear !
Thank you.
Hi Roman,
Thank you for contacting us and I'd be happy to assist.
I've checked the search form and noticed that the "Types of publications" and "Types of events" fields are still showing because their options are not empty.
One option with value '0' exists for both those fields.
Screenshot: hidden link
If you'd like to extend the custom script to hide these fields when only one option with 0 value exists, you can update it to:
jQuery(function($){ $('#term-archive form select').each(function(){ var select = $(this); var options = select.find('option') if ( ! options.length ) { select.parent().hide(); } else if ( (options.length == 1) && (options.val() == 0) ) { select.parent().hide(); } }) })
I hope this helps and 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 very much!