Support » Plugin: WooCommerce » Subcategories woocommerce

  • Hey there!

    I was wondering if it’s possible to show a product’s subcategories of a (main)category.

    I have a category called Producers, which is filled with subcategories like PRO1, PRO2 and PRO3.

    On a product page I would like to show the Producers linked to that specific product. Like PRO1 for example.

    Now this is easy to do if I have only 1 category, however I have more categories besides Producers (Artists etc).

    Does anyone know if this is possible?

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Could add some code to your templates that use the wp_get_post_terms() function to get the list of categories and display them. The taxonomy name for product categories is product_cat. See the Codex for help on using that function:

    It is kind off what I’m looking for, however I still cannot figure out how to actually extract subcategories from a main category (in this case Producers).

    This is what I got so far, $product being global from woocommerce.

    get_the_terms( $post->ID, 'product_cat' );
    echo $product->get_categories();

    Is there any way of doing this in WordPress way?
    Seeing as these lines are just picked up from WordPress.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Subcategories woocommerce’ is closed to new replies.