Skip to content

Instantly share code, notes, and snippets.

@NicBeltramelli
Last active February 12, 2019 15:12
Show Gist options
  • Save NicBeltramelli/9500b6334e728af9740558ee2bd821fb to your computer and use it in GitHub Desktop.
Save NicBeltramelli/9500b6334e728af9740558ee2bd821fb to your computer and use it in GitHub Desktop.
Change number of thumbnails per row on WooCommerce product gallery.
<?php
// Do NOT include the opening php tag.
/**
* Change number of thumbnails per row on product gallery
*
* @author Nic Beltramelli
*
* @param array $wrapper_classes The number of thumbnails per row.
* @return array The modified wrapper class.
*/
add_filter(
'woocommerce_single_product_image_gallery_classes', function ( $wrapper_classes ) {
$columns = 5; // Change this to n. Default is 4.
$wrapper_classes[2] = 'woocommerce-product-gallery--columns-' . absint( $columns );
return $wrapper_classes;
}
);
.woocommerce {
div.product {
/* Product Gallery */
div.images {
.woocommerce-product-gallery__image {
&:nth-child(n+2) {
width: 20%;
}
}
.flex-control-thumbs {
li {
width: 20%;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment