Change quantity of goods per line in woocommerce

I am using woocommerce with themefores template. By default, woocommerce shows 4 products per line, but I want to show 5.

I use a child template, so I duplicate the woocommerce file and there is a content-product.php file inside it.

Here I changed it.

if ( empty( $woocommerce_loop['columns'] ) ) $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 5 ); 

but does not work.

I read how to change this. I found this function that I entered in my functions.php file in a child template

 add_filter('loop_shop_columns', 'custom_loop_columns'); if (!function_exists('custom_loop_columns')) { function custom_loop_columns() { return 8; } } 

but also do not work.

Any idea how to change the quantity of goods per line in woocomerce !!!!

+6
source share
3 answers

Try it,

In function.php function check this function.

 // 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 } } 

Then your child theme adds this,

 // Override theme default specification for product # per row function loop_columns() { return 5; // 5 products per row } add_filter('loop_shop_columns', 'loop_columns', 999); 

check this for more details

Hope this helps.

+5
source

In my case, it works with the following code

I pasted these styles into a child theme of style.css file

 @media only screen and (min-width: 768px) { ul.products li.product { width: 16.05%!important; } } 

and use the following php code in function.php topic

 remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); add_filter('loop_shop_columns', 'loop_columns'); if(!function_exists('loop_columns')) { function loop_columns() { return 5; }} if ( empty( $woocommerce_loop['columns'] ) ) { $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 );} 
+1
source

I know its late, but this code (but it was not easy to find a good solution there) certainly helped me: (functions.php is preferable in a child theme)

  add_filter( 'loop_shop_columns', 'wc_loop_shop_columns', 1, 10 ); /* * Return a new number of maximum columns for shop archives * @param int Original value * @return int New number of columns */ function wc_loop_shop_columns( $number_columns ) { return 5; } 

and in css:

 .columns-4 ul.products li.product {float:left !important;width:29% !important;} .columns-4 .container_inner>ul.products li.product:nth-child(4n+1), .columns-4 .products>ul.products li.product:nth-child(4n+1), div.woocommerce.columns-4 ul.products li.product:nth-child(4n+1), .columns-4 .cross-sells>ul.products li.product:nth-child(4n+1), .columns-4 .woocommerce_with_sidebar ul.products li.product:nth-child(3n+1) { clear:none !important; } 
+1
source

All Articles