change number of product per row in woocommerce

前端 未结 3 1001
执笔经年
执笔经年 2020-12-17 00:55

I am using woocommerce with a themefores template. By default woocommerce show 4 product per row, but I want to show 5.

I am using a child template so I duplicate wo

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-17 01:38

    In my case it works with the following code

    I inserted these styles on child theme's style.css file

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

    and use the following php code into the theme's function.php

    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 );}
    

提交回复
热议问题