简体   繁体   English

分类 WooCommerce 商店页面中的单独产品

[英]Separate products in categories WooCommerce Shop page

On the WooCommerce Shop Page how can you separate products into categories, so that they're displayed with a title and then the respective products below?在 WooCommerce 商店页面上,您如何将产品划分为类别,以便显示标题,然后显示下面的相应产品?

Product Category Title 1 here Products belonging to that category Product Category Title 1 here 属于该类别的产品

Product Category Title 2 here Products belonging to that category here此处产品类别标题 2 属于该类别的产品此处

And so forth...等等……

I tried this code but it is not working.我试过这段代码,但它不工作。

 <?php echo do_shortcode( '[product_category category="category name"]'); ?>

Hi You can get the products using this short code by category [products limit="8" columns="4" category="hoodies, tshirts" cat_operator="NOT IN"] in woocoomerce.嗨,您可以在 woocoomerce 中按类别 [products limit="8" columns="4" category="hoodies, tshirts" cat_operator="NOT IN"] 使用此短代码获取产品。

But on your case you need some customization in to the template you need to go woocommerce template /wp-content/themes/child-theme/woocommerce/archive-product.php contain all shop page code.但是根据您的情况,您需要对模板进行一些自定义,您需要 go woocommerce 模板 /wp-content/themes/child-theme/woocommerce/archive-product.ZE1BFD762321E409CEE34AC0B6E8419 商店代码。

you can add your code/shortocde in the archive-product.php template which will display in shop page.您可以在 archive-product.php 模板中添加您的代码/shortocde,该模板将显示在商店页面中。

Let me know if you need more help.如果您需要更多帮助,请告诉我。

I am just sharing the code example here which you need to replace with the loop in archive-product.php我只是在这里分享代码示例,您需要将其替换为 archive-product.php 中的循环

you need to define custom columns if shortcode columns does not work.如果短代码列不起作用,您需要定义自定义列。

also you need to comment the shop loop.您还需要评论商店循环。

I have tested it and it worked for me.我已经对其进行了测试,并且对我有用。

<div class="col-6">
    
<h1>category 1</h1>

    <?php echo do_shortcode('[products limit="8" columns="2" category="category slug 1"]'); ?>

</div>

<div class="col-6">

    <h1>Category 2</h1>

<?php  echo do_shortcode('[products limit="8" columns="2" category="category slug 2"]'); ?>

</div>

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM