宇讯一资源

change the number of columns in the product list for woocommerce

发布于2021年07月16日 | 暂无评论 | 60阅读 | wordpress

This can be done a number different of ways:

  • Add this to the functions.php file   (不限于模板)
    // 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
    }
    }
    

OR

  • In the woocommerce/templates/content-product.php file change the following line:
    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 4 );
    

    to

    $woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 3 );
    

OR

  • Install and activate this plug. Then go Woocommerce -> Products, scroll down to the Product Columns heading and change the amount to 3.

enter image description here

EDIT: In the custom.js file in the js/ folder change:

jQuery('.article-list .grid_3:nth-child(4n)').after('<div class="clear"></div>');

to

jQuery('.article-list .grid_3:nth-child(3n)').after('<div class="clear"></div>');

暂无评论

发布评论