Skip to main content

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).

Test on staging

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.

functions.php
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).

functions.php
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.

functions.php
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).

functions.php
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.

functions.php
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.

functions.php
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.

functions.php
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.

functions.php
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.

functions.php
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.

functions.php
add_filter( 'daf_interfering_filter_preserve_patterns', function ( $patterns ) {
$patterns[] = 'my_plugin_';
return $patterns;
} );

What's Next