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?
Product Category Title 1 here Products belonging to that category
Product Category Title 2 here Products belonging to that category here
And so forth…
I tried this code but it is not working.
<?php echo do_shortcode( '[product_category category="category name"]'); ?>
Advertisement
Answer
I am just sharing the code example here which you need to replace with the loop in 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>