WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Subcategories woocommerce (4 posts)

  1. Robinero
    Member
    Posted 1 year ago #

    Hey there!

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

    eg:
    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!

    http://wordpress.org/extend/plugins/woocommerce/

  2. IgniteWoo
    Member
    Posted 1 year ago #

    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:

    http://codex.wordpress.org/Function_Reference/wp_get_post_terms

  3. Robinero
    Member
    Posted 1 year ago #

    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.

    <?php
    get_the_terms( $post->ID, 'product_cat' );
    echo $product->get_categories();
    ?>
  4. Robinero
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.