Changing the number of columns in archive pages in woocommerce

余生颓废 提交于 2019-12-07 19:27:47

问题


How can I change the number of columns in archive pages in woocommerce?

It shows 3 in shop pages, but 4 in archive pages.

Thanks


回答1:


This snippet code will change the number of products per page on all archives pages:

add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
    function loop_columns() {
        return 3;
    }
}

This code goes on function.php file of your active child theme or theme

Advice: Sometimes, is necessary to change some css rules, to get the correct display per row.

If you want to target some specific archive pages you can use WooCommerce conditionals tags in an if/else statement as in this thread


References:

  • Change number of products per row
  • WooCommerce conditionals tags
  • WooCommerce - Changing the number of product categories per row


来源:https://stackoverflow.com/questions/38928657/changing-the-number-of-columns-in-archive-pages-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!