skip to Main Content

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"]'); ?>

2

Answers


  1. 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.

    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.

    you can add your code/shortocde in the archive-product.php template which will display in shop page.

    Let me know if you need more help.

    Login or Signup to reply.
  2. 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>
    

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search