• Resolved designsonline

    (@designsonline)


    Hi as the website im building is not yet ready to be indexed or viewed I am going to have to describe clearly the situation.

    I have a website using the Avada theme, Woo commerce is installed.
    For reasons that I wont go in to here it has been decided to use pages that we have designed and built ourselves rather than the default Woo commerce shop categories pages.

    So to scale down the situation imagine a shop with 4 categories called:
    Cat 1, Cat 2,Cat 3,& Cat 4

    under each category are a number of subcategories (lets just pretend only 3 in each)
    so we now have
    Cat 1
    |- Subcat 1a, Subcat 1b, Subcat 1c
    Cat 2
    |- Subcat 2a, Subcat 2b, Subcat 2c
    Cat 3
    |- Subcat 3a, Subcat 3b, Subcat 3c
    Cat 4
    |- Subcat 4a, Subcat 4b, Subcat 4c

    (in reality there will be hundreds of subcategories divided between around 9 top level categories)

    I have created a page for each main category, and wish to just display the subcategories that sit within that category on the page using shortcode.

    So I tried using this shortcode:
    [product_categories category=”cat-1″ limit=”26″ parent=”0″]

    However for some reason this shows me these categories on the page:
    Subcat 1b | Cat 1

    Not what I need, (I want to be shown: Subcat 1a | Subcat 1b | Subcat 1c )

    So I try changing the shortcode to:
    [product_categories category=”cat-1″ limit=”26″ parent=”1″]

    all the categories disappear and none are shown on the page.

    So Next I try:
    [product_categories category=”subcat1a,subcat1b,subcat1c” limit=”26″]

    which shows me:
    Subcat 1a | Subcat 1b | Subcat 1c | Cat 1

    Why is it showing me the main category when I didnt ask for it?
    Also given the number of subcategories that im going to be using in each category I don’t want to have to type them all out each time.

    I need a shortcode that will display all the subcategories of any specified category without needing to list them all in the shortcode.

    Can anyone please help?

    • This topic was modified 6 years, 5 months ago by designsonline.
Viewing 1 replies (of 1 total)
  • jessepearson

    (@jessepearson)

    Automattic Happiness Engineer

    @designsonline I think the wrong shortcode may be being used here. There are two listed here:
    https://docs.woocommerce.com/document/woocommerce-shortcodes/#product-category-shortcodes

    [product_category] – Will display products in a specified product category.
    [product_categories] – Will display all your product categories.

    [product_category] allows the argument category for categories to be passed either by slug or ID. This will display the products of the categories.

    [product_categories] does not have the category argument, however, it has the parent argument, which should be an ID. This will display the categories of the parent specified.

Viewing 1 replies (of 1 total)
  • The topic ‘Shortcode for subcategories’ is closed to new replies.