HUSKY - WooCommerce Product Filter Professional

WooCommerce Filter URL Changes but Products Do Not Change: How to Fix

You tick a color or a category, the loader appears, the address bar changes to something like /shop/?swoof=1&pa_color=red, and the product grid still shows the same products. When the WooCommerce filter URL changes but the products do not change, the filter has done its part: it built the search request. The template that prints the products never read it. This guide shows how to confirm that in two minutes and how to make a theme, page builder or custom template respond to the filter.

Why the filter URL changes but products do not change

HUSKY does not draw the product grid of your shop. It adds its conditions (taxonomies, price, meta fields, text) to the product queries that WooCommerce already runs, and only to those:

  • the main query of the shop page and of product category, tag and attribute archives (WooCommerce's woocommerce_product_query step);
  • the plugin's own [woof_products] shortcode;
  • WooCommerce's product shortcodes such as [products], through woocommerce_shortcode_products_query.

A product list that builds its own WP_Query is outside that path. Page builder product grids, post cards and repeaters, "query loop" elements, theme archive layouts with their own query and hand-written loops in a PHP template all ask the database for products in their own way, so they keep showing the full catalog whatever the filter says. Nothing is broken in the filter; the list simply does not listen.

Two related symptoms have the same root. On a regular page where the filter's script finds no WooCommerce product list, it sends the visitor to the shop page to show the results. And on a "category page" that is really a WordPress page made with a builder, the filter does not know the current category, so it offers every term and searches the whole catalog.

Confirm the cause in two minutes

  1. Read the URL after filtering. If it contains swoof=1 and your choices (/swoof/ followed by them when SEO URLs are on, or only min_price and max_price when the price is the only choice), the filter worked. If the URL does not change at all, the filter never submitted: look for a JavaScript error in the browser console first.
  2. Try the same request on the standard shop page. Copy everything from ?swoof=1 onwards and append it to the URL of your WooCommerce shop page. Filtered products there and unfiltered ones on your page point straight at your page's product list.
  3. Test with a plain shortcode. On a draft page put [woof] and below it [woof_products per_page=12], or WooCommerce's [products limit="12"]. If these filter correctly, use one of the fixes below for your real page.
  4. Check what kind of page it is. Look at the edit screen: a WordPress Page with a product grid on it is not a product archive, even if its URL looks like /category/shoes/.

Fix 1: show the products with [woof_products]

The most reliable fix is to let the plugin print the products. Replace the builder's product element with a Shortcode widget or block that contains [woof_products]:

[woof_products per_page=12 columns=4 is_ajax=1]

The shortcode reacts to the filter on any page, supports AJAX mode with is_ajax=1, and renders each product with your theme's normal WooCommerce product card (the content-product.php template part), so it looks like the shop. To use another template part, change it with the woof_template_part filter.

For a page that should list only one category, give the same condition to both shortcodes, otherwise the filter offers terms from the whole catalog:

[woof taxonomies=product_cat:25]
[woof_products taxonomies=product_cat:25 per_page=12 is_ajax=1]

Replace 25 with the category ID (shown in the URL when you edit the category). WooCommerce's own [products] shortcode is filtered as well, but only with a page reload. If you need it in AJAX mode, write it as [products_woof limit="12" columns="4"]: the plugin wraps it so the results can be swapped without reloading.

Fix 2: make a builder grid or custom WP_Query listen to the filter

When you want to keep the builder's own card design, make its query use the filter's result. The snippet below hooks into pre_get_posts, asks HUSKY which products match the current filter and restricts the grid's query to them. It is a hardened version of the code in Make page builders and custom templates filterable: it leaves wp-admin product lists alone, keeps pagination of the grid working, respects a fixed product selection of the element and shows "no products" instead of the whole catalog when nothing matches.

/**
 * HUSKY: apply the active filter to product lists that run their own query
 * (page builder grids, post cards, query loops, custom templates).
 * Child theme functions.php or a code snippets plugin.
 */
add_action( 'pre_get_posts', function ( $query ) {
    static $busy = false;

    if ( $busy || ! function_exists( 'woof' ) || $query->is_main_query() ) {
        return;
    }
    // Keep the product lists in wp-admin untouched.
    if ( is_admin() && ! wp_doing_ajax() ) {
        return;
    }
    // Product queries only.
    if ( ! in_array( 'product', (array) $query->get( 'post_type' ), true ) ) {
        return;
    }
    // WooCommerce archives and [woof_products] are filtered already.
    if ( 'product_query' === $query->get( 'wc_query' ) ) {
        return;
    }
    // Only while a filter is active: ?swoof=1, an SEO URL,
    // or ?min_price=...&max_price=... when only the price is set.
    $request = woof()->get_request_data();
    if ( ! isset( $request[ woof()->get_swoof_search_slug() ] ) && ! isset( $request['min_price'] ) ) {
        return;
    }
    // Optional: limit to one page.
    // if ( ! is_page( 123 ) ) { return; }

    $was_doing = isset( $_REQUEST['woof_products_doing'] );
    $args      = woof()->woof_products( array( 'get_args_only' => 1 ) );

    // All matching IDs, whatever page of the grid is open.
    $args['fields']         = 'ids';
    $args['posts_per_page'] = -1;
    $args['paged']          = 1;
    $args['no_found_rows']  = true;
    $args['orderby']        = 'ID';
    unset( $args['meta_key'] );

    $busy = true;
    $ids  = ( new WP_Query( $args ) )->posts;
    $busy = false;

    if ( ! $was_doing ) {
        unset( $_REQUEST['woof_products_doing'] );
    }

    // Respect a fixed product selection of the element itself.
    $own = array_filter( array_map( 'intval', (array) $query->get( 'post__in' ) ) );
    if ( $own ) {
        $ids = array_values( array_intersect( $ids, $own ) );
    }

    // No match: show "no products" instead of the whole catalog.
    $query->set( 'post__in', $ids ? $ids : array( 0 ) );
} );

How it works: woof()->woof_products( array( 'get_args_only' => 1 ) ) returns the query arguments that [woof_products] would use for the current request, without running it. The snippet turns them into a list of matching product IDs and hands that list to the grid as post__in. The grid keeps its own layout, sorting and page size. The same hook covers a WP_Query you write yourself in a template, as long as it queries the product post type.

Every product query on a filtered page now follows the filter, including sliders such as "best sellers" or "related products" in a footer. If that is not what you want, uncomment the is_page() line and put the ID of the page with the grid; this also spares one extra database query for every other product list on the page.

AJAX mode needs the two shop loop hooks

With Try to ajaxify the shop set to Yes (WooCommerce → Settings → Products Filter → Options), the plugin wraps the product list in its own container. It opens the container on the woocommerce_before_shop_loop hook and closes it on woocommerce_after_shop_loop. After each filter change it asks the server for new HTML and replaces the content of that container. The standard WooCommerce archive template calls both hooks; many builder layouts and custom templates do not. The result is one of three symptoms:

  • Neither hook is called: there is no container to replace, so every filter change reloads the whole page.
  • Only the first hook is called: the opened container is never closed and swallows the rest of the layout, for example the second column or the sidebar, which suddenly appears inside the product column.
  • The cards change their look after filtering: AJAX results are rendered on the server by [woof_products] with the standard WooCommerce product card, not by the builder's card design. Default quantity fields or add-to-cart buttons appear where the builder had hidden them.

If you control the template code, call both hooks around the loop:

<?php
// Product list part of your theme template.
do_action( 'woocommerce_before_shop_loop' );

woocommerce_product_loop_start();
while ( have_posts() ) {
    the_post();
    wc_get_template_part( 'content', 'product' );
}
woocommerce_product_loop_end();

do_action( 'woocommerce_after_shop_loop' );

Everything between the two hooks is replaced on each AJAX request, so wrapper markup you want around each product belongs in content-product.php, not in the archive template. Custom conditions of your own loop (for example "products from the last 60 days") are not part of the AJAX result, because the server renders it with [woof_products]; add such conditions with the woof_products_query hook or use redirect mode.

If you cannot change the template, which is the usual case with builders, set Try to ajaxify the shop to No. In redirect mode every filter change loads the filtered URL, and the snippet from Fix 2 makes the builder grid show the right products. With autosubmit on, each choice is applied right away, only with a page load instead of an AJAX swap.

The filter jumps to the shop page or ignores the category

Results open on the shop page. On a page that is not a product archive, the filter's script looks for a WooCommerce product list: an element with the class products inside a .woocommerce container, or the plugin's own output. If it finds none, it sends the search to the shop page, and the filter on your page seems to disappear. Fix 1 solves it; the shortcode setups for landing pages and the homepage are in product filter on a custom page. If your builder grid already reacts to the filter thanks to Fix 2 but uses different markup, tell the script to stay on the page:

/**
 * HUSKY: keep filter results on this page instead of the shop page.
 * Child theme functions.php or a code snippets plugin.
 */
add_action( 'wp_footer', function () {
    if ( is_page( 123 ) ) { // ID of the page with the product grid
        echo '<script>var woof_not_redirect = 1;</script>';
    }
} );

The filter offers terms from other categories. The plugin takes the current category from WordPress (the queried object of a product taxonomy archive). A WordPress page built to look like a category does not have one, so the filter works with the whole catalog. Use the real category archive and style it with your builder's archive or theme-builder template, or pass taxonomies=product_cat:ID to both shortcodes as shown in Fix 1. A custom theme built without WooCommerce support can have the same effect on real archives; declaring add_theme_support( 'woocommerce' ) in an after_setup_theme callback fixes the detection, though the theme's product templates may then need adjusting. If the page is a real archive and the category is still not detected, set Additional check of the category page to Yes under Advanced → Options. Block themes get this check automatically. To hide terms that have no products in the current category, see how to show only the filter options of the current category.

Routing conflicts: SEO URLs and permalinks

With the SEO URL request extension on, the filter becomes part of the path, for example /shop/swoof/color-red/, instead of a query string. Some builders resolve URLs and templates themselves (Bricks is a known case) and do not recognise that path, so the filter UI works while the products never change, or the page falls back to an unfiltered template. To test, open Advanced → SEO URL request and set Enable/Disable to No, clear every cache and filter again. If the plain ?swoof=1&... links work, the routing is the cause; keep SEO URLs off on that site.

SEO URLs also need pretty permalinks. With the Plain setting under Settings → Permalinks, choose any other structure, save, and test again.

Common builder situations

What shows the productsWhat to do
Builder product grid, post cards, repeater or query loop element (Avada Post Cards, Oxygen Repeater, Bricks query loop, a Query Loop block with a custom query)Fix 2, redirect mode. Or replace the element with [woof_products].
Theme-builder layout that replaces the shop or category template (Avada layouts, YOOtheme, Flatsome, Beaver Themer, Breakdance)Works in redirect mode when the layout uses the WooCommerce loop. AJAX mode only if the layout calls both shop loop hooks; otherwise set Try to ajaxify the shop to No.
Elementor product widgets and loop gridsSee making Elementor product grids filterable.
Hand-written WP_Query in a PHP templateFix 2 covers it; for AJAX mode add the two hooks.
Another plugin that replaces the product query or templateDeactivate it for a test. If the filter then works, that plugin needs to use the standard WooCommerce query.

If it still does not work

  • Test logged out in a private window. A page cache that ignores the query string serves the same unfiltered HTML for every filter URL; exclude URLs containing swoof from the page cache.
  • After adding the snippet, open a filter URL directly. If the grid is still unfiltered, the element probably does not query the product post type, or it loads its products later by its own AJAX request without the filter parameters (some "load more" buttons do this).
  • If the first page filters correctly but page 2 shows a 404 or unfiltered products, the grid's pagination links drop the filter parameters. Check that the page 2 link still contains swoof=1 and your choices; more causes are in filter pagination not working.

If the shortcode test from the first section works and your template still does not, open a topic on the HUSKY support forum with a link to the page, the theme or builder and the element that shows the products.