How to change the number of columns in the product gallery

Your fancy clothes store is ready, you have the best clothes of the city, and hundreds of photos of them, ready to be uploaded in your store.
They will look great online, people will go crazy to buy them and you will be rich!

But how to use all those awesome photos you made? They just don’t fit, the product gallery in the single product page shows only three photos per row and the page looks too long.

What if I say you that you can change the number of photos per row with one line of code?

Disclaimer: If this snippet does not work, most probably your theme is overriding the template product-gallery.php and it removed the filter within it.

Open the file functions.php located in wp-content/themes/your-theme-name/ and add this code at the end of it:

add_filter( 'woocommerce_product_thumbnails_columns', create_function( '', 'return 4;' ) );

view raw


hosted with ❤ by GitHub

From now on, the single product gallery will show four pictures per row. You can further increase that by changing the value in the snippet.
Be careful though, you will probably need to change your CSS too to make them look properly or they will probably stretch or be too small.

More Posts That You Might Like…

Leave a Reply



Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Blog at

%d bloggers like this: