• Resolved htisamit

    (@htisamit)


    Hi All,

    On home page of a website I am creating, I want to add a section where its shows parent category and when click on parent category, it shows all subcategories and when I click on sub category it show all products under that subcategory.

    So here is flow Parent Category >> Sub Category >> Products

    Is there any way to achieve?

    Regards,
    Amit

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Sérgio L. a11n

    (@csnlima)

    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:

    1. Go to Appearance > Customize > WooCommerce > Product Catalog
    2. In the first dropdown menu “Shop page” Select “Show Categories”
    3. Under “Category pages” select “Show Subcategories”
    4. 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,

    Thread Starter htisamit

    (@htisamit)

    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

    Plugin Support Sérgio L. a11n

    (@csnlima)

    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,

    Thread Starter htisamit

    (@htisamit)

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Nested Category on Home Page’ is closed to new replies.