PHP hooks
Overview
WPEnhanced Ajax Filter Blocks exposes WordPress apply_filters and do_action hooks during block rendering. Use these to adjust settings values, markup conditions, and Pro feature output without editing plugin core.
Hook names use the daf_ prefix (Divi Ajax Filter heritage). They are stable extension points for themes and companion plugins.
Always test hooks on staging. Incorrect filters can break filter HTML or hide required controls.
Naming pattern
daf_{block}_{context}_{setting}
Examples:
daf_filterposts_render_mobile_toggle— Filter Posts mobile toggle settingdaf_filter_posts_item_render_radio_appearance— Filter item radio/swatches appearancedaf_archiveloop_render_enable_load_more— Archive Loop load more (Pro)
Most filters receive ( $default, $value ) or ( $value, $attributes ). Check the second parameter in your hook callback—it is the value from block attributes.
Filter Posts block
Common filters on Filter Posts render:
| Hook | Purpose |
|---|---|
daf_filterposts_render_scrollto_section | Scroll target section ID after filter |
daf_filterposts_render_mobile_toggle | Mobile filter drawer on/off |
daf_filterposts_render_appearance | Panel appearance (normal, toggle, slide) |
daf_filterposts_render_filter_param_container | Selected-filter chips container |
daf_filterposts_render_synchronize | Sync multiple filter panels |
Condition filters (return boolean) control whether UI features render:
daf_filterposts_render_mobile_toggle_conditiondaf_filterposts_render_appearance_toggle_conditiondaf_filterposts_render_appearance_slide_condition
Actions:
daf_filterposts_render_mobile_toggle_js— Inject JS for mobile toggle buttondaf_filterposts_render_toggle_js— Inject JS for toggle/slide appearance
Filter Posts Item block
| Hook | Purpose |
|---|---|
daf_filter_posts_item_render_show_filter_parameters | Show active filter chips for this item |
daf_filter_posts_item_render_radio_appearance | Radio vs swatch appearance |
daf_filter_posts_item_render_taxonomy_filter_type | Taxonomy control type override |
daf_filter_posts_item_render_range_values | Price/range min/max source |
daf_filter_posts_item_render_conditional_logic | Conditional filter rules (Pro) |
daf_filter_posts_item_conditional | Conditional settings array (Pro) |
daf_filter_posts_item_style | Inline CSS for swatch sizing |
Pro render actions (require Pro active):
daf_filter_posts_item_render_acf_prodaf_filter_posts_item_render_acf_map_prodaf_filter_posts_item_render_posttypes_pro
Archive Loop block
| Hook | Purpose |
|---|---|
daf_archiveloop_render_enable_load_more | Load more / infinite scroll (Pro) |
daf_archiveloop_render_display_type | List vs grid display (Pro) |
daf_archiveloop_render_grid_style | Grid layout style |
Example: force mobile toggle on
add_filter( 'daf_filterposts_render_mobile_toggle', function ( $default, $value ) {
return 'on';
}, 10, 2 );
Example: adjust swatch appearance globally
add_filter( 'daf_filter_posts_item_render_radio_appearance', function ( $default, $value ) {
if ( is_shop() ) {
return 'swatch';
}
return $value;
}, 10, 2 );
Query modification
Block attribute hooks adjust rendered settings, not raw WP_Query in all cases. For deep query changes, prefer:
- Archive Loop block query settings in the editor
- Advanced loop queries (Pro) for complex base queries
- Custom code targeting REST query endpoints (contact support for guidance on supported REST extension points in your version)
Best practices
- Prefix your callback functions or use a singleton class.
- Use priority
10unless you must run before/after other plugins. - Return the original value when your condition does not apply.
- Do not
echofrom filter callbacks—return modified values; use actions for output.
What's next
- JavaScript hooks —
divi_filter_completedevent - Advanced loop queries (Pro) — Complex queries without code
- PHP hooks in WordPress — WordPress hook fundamentals