PHP hooks and filters
Use these PHP hooks to customize Ajax Filter queries and markup from a child theme or small custom plugin. For front-end JavaScript after AJAX completes, see Developer hooks (JavaScript).
Hooks run during AJAX filter and Load More requests. Always test on a staging site and keep callbacks lean.
Query arguments
divi_archive_post_args
Filter the WP_Query arguments before filter AJAX runs.
add_filter( 'divi_archive_post_args', function ( $args ) {
// Example: always exclude a sticky custom post ID.
$args['post__not_in'] = array_merge(
(array) ( $args['post__not_in'] ?? array() ),
array( 123 )
);
return $args;
} );
db_archive_module_args
Filter Archive Loop module query arguments (Divi 4 Archive Loop path and related merge helpers).
add_filter( 'db_archive_module_args', function ( $args ) {
$args['ignore_sticky_posts'] = true;
return $args;
} );
Loop item actions
de_ajaxfilter_before_shop_loop_item / de_ajaxfilter_after_shop_loop_item
Fire before and after each item HTML is built in filter and Load More REST responses. Useful for injecting markup or triggering custom logic around loop items.
add_action( 'de_ajaxfilter_before_shop_loop_item', function () {
echo '<div class="my-loop-item-wrap">';
} );
add_action( 'de_ajaxfilter_after_shop_loop_item', function () {
echo '</div>';
} );
Range slider bounds
divi_filter_range_min / divi_filter_range_max / divi_filter_range_from / divi_filter_range_to
Override minimum, maximum, and default “from/to” values for number/range filters (including price-style ranges).
add_filter( 'divi_filter_range_min', function ( $min ) {
return 0;
} );
add_filter( 'divi_filter_range_max', function ( $max ) {
return 500;
} );
Map / geocoding
daf_geocode_address
Provide custom geocoding for map radius filters. Return coordinates your implementation understands; use this when the default geocoder is insufficient.
add_filter( 'daf_geocode_address', function ( $result, $address ) {
// Return your geocode payload or $result to keep the default.
return $result;
}, 10, 2 );
Layout rendering
de_daf_use_standard_layout_rendering
Force standard vs compatibility layout rendering regardless of the admin setting.
add_filter( 'de_daf_use_standard_layout_rendering', function ( $use_standard ) {
// Return false to prefer Compatibility-style handling.
return $use_standard;
} );
de_daf_trust_layout_output
Skip stricter layout sanitization when you fully trust custom layout HTML.
add_filter( 'de_daf_trust_layout_output', '__return_true' );
Prefer the admin Layout Rendering Mode toggle under Caching and performance before using these filters.
Filter item markup
modify_classes_filterpostitem
Add or change CSS classes on Filter Posts Item markup.
add_filter( 'modify_classes_filterpostitem', function ( $classes ) {
$classes[] = 'my-custom-filter-item';
return $classes;
} );
Infrastructure
daf_rest_namespace
Change the REST API namespace prefix (default is divi-ajax-filter). Only change this if you control all clients that call the endpoints.
add_filter( 'daf_rest_namespace', function ( $namespace ) {
return $namespace;
} );
daf_interfering_filter_preserve_patterns
Preserve selected third-party query-var patterns when Ajax Filter strips interfering query filters during AJAX requests.
add_filter( 'daf_interfering_filter_preserve_patterns', function ( $patterns ) {
$patterns[] = 'my_plugin_';
return $patterns;
} );
Related
- Developer hooks (JavaScript) —
divi_filter_completedand execution order - How to add JavaScript before or after the ajax filter — Quick FAQ snippet
- Caching and performance — Layout Rendering Mode
What's Next
- Developer hooks (JavaScript) — Front-end events after AJAX
- Filters not updating — Target loop and wiring issues
- URL sync and shareable filters — How filter state reaches the URL