Skip to content

Instantly share code, notes, and snippets.

@10h30
Forked from anonymous/functions.php
Created May 30, 2017 16:57
Show Gist options
  • Save 10h30/b33edb778d004f6c26e329281a897454 to your computer and use it in GitHub Desktop.
Save 10h30/b33edb778d004f6c26e329281a897454 to your computer and use it in GitHub Desktop.
Change the number of products per row in WooCommerce
// Change number or products per row to 3
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
.woocommerce ul.products li.product {
width: calc( ( 100% - ( 30px * ( 3 - 1 ) ) ) / 3 );
float: left;
margin-right: 30px;
}
.woocommerce ul.products li.product:nth-child(3n+3) {
margin-right: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment