Hide Empty Hierarchy Levels in Select Filters
This snippet hides select dropdown levels in JetSmartFilters hierarchy filters if the select has no options except the placeholder. It improves filter UI by removing redundant empty selection levels.
Specifications
Hide Empty Hierarchy Levels in Select Filters
7 January, 2026
-
Plugin
-
Category
-
Programming languages
Installing Instruction
- Copy the entire code snippet to your clipboard.
- You can add the snippet in one of two ways:
-
Option A: Using a Custom Code Plugin (Recommended)
- Install and activate a plugin such as WPCode Lite, Code Snippets, or Simple Custom CSS and JS.
- Create a new snippet of the appropriate type:
- JavaScript snippet → paste JS without <script> tags
- CSS snippet → paste CSS without <style> tags
- Save and activate the snippet.
-
Option B: Using Theme Files or a Custom HTML Widget
- Navigate to WordPress Dashboard > Appearance > Theme File Editor.
- Open an appropriate theme file (for example, header.php or footer.php), or add a Custom HTML widget in the desired area.
- Paste the code snippet:
- Keep <script> tags for JavaScript
- Keep <style> tags for CSS
- Save your changes.
-
Option A: Using a Custom Code Plugin (Recommended)
Example Use Case
Use this snippet to enhance user experience in JetSmartFilters with hierarchical filters by dynamically hiding empty dropdown levels.
Applicable scenarios:
- E-commerce and directory sites: Clean up filters to show only relevant options.
- Complex category filters: Ensure users do not see empty filter dropdowns.
- Any site using JetSmartFilters hierarchy filters: Improve filter clarity and usability.
Specifications
Hide Empty Hierarchy Levels in Select Filters
7 January, 2026
-
Plugin
-
Category
-
Programming languages