Conditional filters
Requires WPEnhanced Ajax Filter Blocks Pro.
What conditional filters do
Conditional filters show or hide individual Filter Posts Item blocks depending on what the visitor selected elsewhere—similar to conditional logic in forms.
Examples:
- Show Subcategory only after a Parent category is selected
- Show Size only when Category: Clothing is active
- Hide Map radius until Region is chosen
Enable conditional logic
- Select a Filter Posts Item in the block editor.
- Open Conditional logic settings (Pro).
- Enable Conditional logic.
- Add rules:
- When [filter item / field] [is / is not] [value]
- Choose Match all (AND) or Match any (OR) for multiple rules.
- Save and test on the front end.
Hidden filters receive the conditional_hide class and are excluded from active filtering until rules pass.
Subcategory patterns
A common pattern for hierarchical taxonomies:
- Filter item A: Parent category (Select)
- Filter item B: Child category (Select), conditional on A matching parent term
When the parent changes, child options refresh via AJAX. Test that clearing the parent hides or resets the child.
Conditional categories (dynamic options)
Pro supports conditional category filters where child term lists depend on the parent selection. Configure parent and child items with matching conditional rules and taxonomy hierarchy settings.
Developer note
Conditional visibility re-evaluates after filter updates. Custom scripts can hook handle_conditional_fields or listen for divi_filter_completed to sync third-party UI.
PHP filter: daf_filter_posts_item_render_conditional_logic — see PHP hooks.
Troubleshooting
| Issue | Check |
|---|---|
| Filter never appears | Rules too strict; test with OR instead of AND |
| Filter flashes hidden | Initial load vs AJAX—verify first-load conditional AJAX setting |
| Wrong results | Hidden filter may still hold old values—use Reset |
What's next
- Filter Posts Item block — Base filter item settings
- ACF fields and map — Location-based conditional patterns
- PHP hooks —
daf_filter_posts_item_conditional