Hi @htisamit.
Yes, if I understand you correctly, this can be done with WooCommerce setting.
Your shop page can display Category Pages can display Products or Subcategories within a Category, or both. Let me show you how:
- Go to Appearance > Customize > WooCommerce > Product Catalog
- In the first dropdown menu “Shop page” Select “Show Categories”
- Under “Category pages” select “Show Subcategories”
- Save the changes
For both options, you can also display the products under the categories or subcategories.
Get to know more about it here: https://woocommerce.com/document/woocommerce-customizer/
If you need a more robust solution, take a look at this plugin:
https://woocommerce.com/products/woocommerce-nested-category-layout/
I hope this information helps!
Best,
Hi @csnlima I am not using this on shop page. I want a section on home page. Customizer setting is for Shop page I guess.
Regards,
Amit
Hi @htisamit,
Thanks for clarifying! So this can be done with native WooCommerce shortcodes, but not exactly as you expect.
You can create a new page with the following shortcode:
[product_categories number="0" parent="0"]
This will display the top categories, however, once you click on a category, you will be redirected to a page with the subcategories but also with the products.
Get to know more about shortcodes here: https://woocommerce.com/document/woocommerce-shortcodes/
To archive exactly as you described (Categories > Subcategories > Products), the plugin suggestion I gave you before, is indeed more accurate:
https://woocommerce.com/products/woocommerce-nested-category-layout/
I want a section on home page.
Let me know more details of how do you want to display the section in the home page, if you need help with this as well.
I hope this helps!
Best,
@csnlima I achieved this using your first message. Thanks a lot. Now its showing parent category and when I click on parent category I land on subcategory.
When I click on subcategory I can see the products in that sub category.
This is what I wanted. Thanks a lot.
One last help. Its not showing the category which has no product. But I want to show all categories even if there is no product. Is there any way.
Regards,
AMit
Hi @htisamit
One last help. Its not showing the category which has no product. But I want to show all categories even if there is no product. Is there any way.
This can be done by adding the following code.
add_filter( 'woocommerce_product_subcategories_hide_empty', '__return_false' );
This code should be added to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update.
https://woocommerce.com/document/customizing-woocommerce-best-practices/#section-4
We’ve not heard back from you in a while, so I’m marking this thread as resolved. If you have further questions, please feel free to open a new topic.