WooCommerce PHP Beginner Requires WooCommerce

Change the Number of Shop Columns

Change how many products sit side by side on shop and category pages in classic themes.

Tested on WordPress 7.1 PHP 8.3 Updated
functions.php 3 lines
add_filter( 'loop_shop_columns', function (): int {
	return 3;
}, 20 );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

WooCommerce shows four products per row by default. Larger product photos often look better three across. This snippet changes the column count.

How it works

The loop_shop_columns filter tells WooCommerce how many products go in each row. It adds a columns-3 class to the product list and marks the first and last product in each row.

Your theme’s CSS does the actual layout, so most themes respond to the new class straight away.

Things to watch

  • A few themes hard-code their column layout and ignore this setting. In that case, change the columns in the theme’s own options.
  • Update the products-per-page number so it divides evenly by the new column count.
  • Block themes set columns in the Product Collection block instead.

How to test it

Open the shop. Products should now sit three across on desktop.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only