Skip to content

Instantly share code, notes, and snippets.

@josialoos
Last active September 15, 2024 21:41
Show Gist options
  • Save josialoos/04c46c462f25cc0c5305e118e2b4cb70 to your computer and use it in GitHub Desktop.
Save josialoos/04c46c462f25cc0c5305e118e2b4cb70 to your computer and use it in GitHub Desktop.
Woocommerce: Activate image gallery features on archive page same as on product page
Add this to your functions.php in wordpress theme folder:
add_action( 'wp_enqueue_scripts', 'gallery_scripts', 20 );
function gallery_scripts() {
if ( is_archive()) {
if ( current_theme_supports( 'wc-product-gallery-zoom' ) ) {
wp_enqueue_script( 'zoom' );
}
if ( current_theme_supports( 'wc-product-gallery-slider' ) ) {
wp_enqueue_script( 'flexslider' );
}
if ( current_theme_supports( 'wc-product-gallery-lightbox' ) ) {
wp_enqueue_script( 'photoswipe-ui-default' );
wp_enqueue_style( 'photoswipe-default-skin' );
add_action( 'wp_footer', 'woocommerce_photoswipe' );
}
wp_enqueue_script( 'wc-single-product' );
}
}
@oufleurcrea
Copy link

Don't work for me !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment