WooCommerce Product Gallery Broken After WordPress 7 Update

WooCommerce product gallery zoom and lightbox dead after WordPress 7? Here is the script enqueue change that silently breaks it and the fix that brings it back.
WooCommerceWordPressjQuery
May 28, 20265 min read922 words

The Problem

A client called me on Monday because their single product page suddenly looked like a static brochure. Thumbnails were there, the main image was there, but clicking a thumbnail did nothing. The lightbox did not open, the zoom-on-hover stopped, and on mobile the swipe gallery had collapsed to a vertical stack.

The only thing they had done was run the WordPress 7.0 update over the weekend. WooCommerce 10.7, no plugin changes, no theme changes. The browser console was clean except for one warning:

[Deprecation] jQuery.migrate: JQMIGRATE: Migrate is installed, version 3.5.2
flexslider.min.js?ver=10.7.0:1 Uncaught TypeError: $(...).flexslider is not a function

I have seen the flexslider is not a function message a hundred times over the years, but never after a core WordPress update. Reverting to 6.9 brought the gallery back. So 7.0 was the trigger, and the fix had to live somewhere between the script registration and the theme.

Why It Happens

WordPress 7.0 finished a deprecation cycle that started in 6.7. jquery-migrate is no longer registered as a hard dependency of jquery-core, and the bundled jQuery moved to 3.7.1. Themes that registered scripts against the literal handle jquery used to get migrate for free, which papered over a lot of legacy code. Migrate is now an opt-in handle (jquery-migrate).

WooCommerce ships its own copy of flexslider, registered as flexslider with jquery as a dependency. Flexslider 2.x was written against jQuery 1.10. It calls $.browser, which migrate used to polyfill. With migrate gone, the initialiser throws on first run and the whole gallery JS never wires up. The thumbnails render because they are static markup, the click handler never attaches because the script blew up before reaching it.

The second wrinkle is the theme. Storefront and most modern themes register their own enqueue stack with add_theme_support( 'wc-product-gallery-zoom' ) and friends. If the theme registered those before the migrate change, the conditional that loads flexslider runs unchanged, but the script it loads is broken. So the symptom is identical across themes that look very different on disk.

The WordPress 7.0 field guide flags this in one paragraph near the bottom, which is easy to miss when the release post is full of block editor news.

The Fix

Two layers. Re-enqueue migrate for the front end, then make sure the WooCommerce gallery handles actually load.

Step 1: Re-register jquery-migrate on the front end. Drop this into your child theme functions.php or a small mu-plugin:

add_action( 'wp_enqueue_scripts', function () {
    if ( is_admin() ) {
        return;
    }
    wp_enqueue_script(
        'jquery-migrate',
        '/wp-includes/js/jquery/jquery-migrate.min.js',
        array( 'jquery-core' ),
        '3.5.2',
        false
    );
}, 1 );

Loading it at priority 1 puts it ahead of flexslider, which is enqueued at the default 10. The false for $in_footer matters: flexslider's IIFE runs immediately, so migrate must be parsed first.

Step 2: Confirm gallery support is declared. Some themes lost their gallery support call during the 7.0 migration because the function signature for add_theme_support started erroring on unknown features. Verify it in the theme bootstrap:

add_action( 'after_setup_theme', function () {
    add_theme_support( 'wc-product-gallery-zoom' );
    add_theme_support( 'wc-product-gallery-lightbox' );
    add_theme_support( 'wc-product-gallery-slider' );
} );

If those three lines are missing, WooCommerce will not even register the gallery scripts. The page still renders, but with a dumb thumbnail grid. I have walked into client sites where the previous developer removed the slider support to fix a different bug and never put it back.

Step 3: Verify the script chain in DevTools. Hard refresh the product page and check the Network tab. You should see all four of these load with a 200:

jquery-core.min.js
jquery-migrate.min.js
flexslider.min.js
zoom.min.js
photoswipe.min.js (only if lightbox is enabled)

If migrate still does not show, a caching plugin is concatenating scripts and dropping the new handle. Purge the cache and exclude jquery-migrate from concatenation. WP Rocket has a known exclusion list pattern; on LiteSpeed Cache the option is under JS Combine excludes.

Step 4: Test on a real product. Click a thumbnail, hover for zoom, and click the main image for the lightbox. All three are separate scripts, and it is common to have one work and two fail because flexslider initialised but PhotoSwipe never got the chance.

curl -s "https://your-site.com/product/sample-shoes/" \
  | grep -o "flexslider\|photoswipe\|zoom.min.js"

If the grep returns nothing on a logged-out request, a cache is serving a stale HTML version that pre-dates the enqueue fix. Clear the page cache and recheck.

If you operate WooCommerce at any scale, do not patch this on production blind. Run it on staging first because the migrate handle change can shake loose other legacy scripts that were quietly depending on $.browser or $.live. The fix above brings the gallery back without re-introducing migrate site-wide for the admin, which is what you want.

Stuck on a WordPress 7 update that broke the storefront? That is exactly the kind of mess I get paid to clean up. See my services. For a related WooCommerce 10.7 regression after the same update cycle, read WooCommerce 10.7 short description missing in admin.

Back to blogStart a project