doulangchao8934 2018-06-05 14:17
浏览 52

产品分为2行而不是3行,但仅适用于选定的产品类别

I'm working on site where I need to setup products to be showed in to 2 rows, instead of the default 3 for all other products categories. I searched into Stack and Google and found this useful answer, where the asnwer was writen in this function:

add_filter('loop_shop_columns', 'loop_columns'); 
if (!function_exists('loop_columns')) {
    function loop_columns() {
        if ( is_product_category('torres-elevadoras')) { // wanted product category
            return 2;
        } 
}

This doesn't seem to take effect when inserting into the functions.php file into my theme. Are some coding changes into latest Woo 3.4.1 that making this function not work anymore?

EDIT: When inserting this CSS, it shows me products into two columns, but for all category. How to apply for wanted product category?

.woocommerce div.product {
    width:50%;
}
  • 写回答

1条回答 默认 最新

  • duancunsu9209 2018-06-05 14:34
    关注

    I was able to fix myself using this CSS rule:

    .term-torres-elevadoras.woocommerce div.product {
    width:50%;
    }
    

    To explain how i fixed. on category page, press Ctrl+U and search for this string into code:

    <body class="archive
    

    and will found something like this:

    image

    Then get slug: term-category-name and use it in combination with other element CSS. That is.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化