Nicola Mustone

Happiness Lead @ Automattic



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

functions.php

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.

Advertisements

Subscribe to This Blog

Receive new articles from this blog directly in your inbox! No spam guaranteed!

Join 651 other subscribers

Contribute to Improving This Blog

Did you enjoy this article? Was it helpful? Contribute to help me write more articles! The funds collected from this blog are reinvested directly into improving my skills or the blog so that I can provide more and better content!

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

€5.00
€15.00
€100.00
€5.00
€15.00
€100.00
€5.00
€15.00
€100.00

Or enter a custom amount


Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly
Advertisements

More Posts That You Might Like…


Leave a Reply

Advertisements

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

About The Author

Hi, I’m Nico! Support Lead at Automattic, championing WordPress.com & WooCommerce. Off-duty, I’m at Elemental Beacon, leading epic D&D adventures. Let’s connect, whether it’s about WordPress or a quest!

Advertisements

Don't Miss a Thing!

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

Continue Reading

%d bloggers like this: