Advanced Ajax Layered Navigation developer reference

Filters for pointing Advanced Ajax Layered Navigation at your theme’s markup.

Beka Rice Avatar

Written by

Last updated


Advanced Ajax Layered Navigation refreshes parts of the shop page using WooCommerce’s standard markup. If your theme uses different IDs or classes, these filters tell the plugin where the products and other refreshed areas are, without editing the theme or WooCommerce. Add them in a code snippets plugin or your child theme’s functions.php. For setup, see Get started with Advanced Ajax Layered Navigation.

Theme and code customizations are outside our support. If you’re not comfortable with code, ask a developer to add these.

When you’d use this

  • Filtering changes the address bar but the products on the page don’t change.
  • Parts of the page, such as a custom result count or pagination, stay stale after filtering.
  • Your theme’s scripts, such as a product slider or lazy-loaded images, stop working after a filter refresh.

Containers to refresh

sod_ajax_layered_nav_containers

The list of selectors whose contents are replaced after each filter change. By default: #products, .products, #pagination-wrapper, .woocommerce-pagination, .woo-pagination, .pagination, .widget_layered_nav, .widget_layered_nav_filters, .woocommerce-ordering, .sod-inf-nav-next, .woocommerce-result-count, .woocommerce-info and .widget_ajax_layered_nav_clear. Add your theme’s own containers:

add_filter( 'sod_ajax_layered_nav_containers', function( $containers ) {
	$containers[] = '#your-id';
	$containers[] = '.your-class';
	return $containers;
} );

sod_ajax_layered_nav_product_container

The one element that holds the products, which shows the loading message while products load. Default #products, which the plugin wraps around WooCommerce’s shop loop. Return your theme’s ID or class if its products sit elsewhere:

add_filter( 'sod_ajax_layered_nav_product_container', function() {
	return '.your-class';
} );

Other filters

FilterWhat it setsDefault
sod_ajax_layered_nav_clickablesElements that start a refresh when clicked.widget_layered_nav a, .widget_layered_nav input[type="checkbox"], .widget_ajax_layered_nav_filters a, .widget_layered_nav_clear a
sod_ajax_layered_nav_orderbyThe sorting form.woocommerce-ordering
sod_ajax_layered_no_productsThe "no products found" notice.woocommerce-info
sod_ajax_layered_nav_scrolltopWhether the page scrolls to the products after filteringtrue
sod_ajax_layered_nav_offsetSpace left above the products when scrolling, in pixels150

JavaScript event

aln_reloaded

Fires on body after each filter refresh. Use it to restart scripts that the refreshed content needs:

jQuery( 'body' ).on( 'aln_reloaded', function() {
	// Re-initialize a slider or lazy-loaded images here.
} );

Keep learning