• Hey everyone,

    I have a bunch of product categories on my site that’s using Woocommerce and those “parent” categories have multiple subcategories which have multiple subcategories of their own. An example menu structure would be the following:

    • Animals
    • Land
    • Cats
    • Dogs
    • Sea
    • Sharks
    • Whales
    • Cars
    • Sports
    • Ferrari
    • Porsche
    • SUV
    • Volvo
    • Audi

    What I’d like to do is to display a certain widget on the parent product category and on all of the pages of its subcategories. So using the above example menu the result I’m going for would be the following:

    • Animals (widget for Animals)
    • Land (widget for Animals)
    • Cats (widget for Animals)
    • Dogs (widget for Animals)
    • Sea (widget for Animals)
    • Sharks (widget for Animals)
    • Whales (widget for Animals)
    • Cars (widget for Cars)
    • Sports (widget for Cars)
    • Ferrari (widget for Cars)
    • Porsche (widget for Cars)
    • SUV (widget for Cars)
    • Volvo (widget for Cars)
    • Audi (widget for Cars)

    Is it possible to achieve this via a certain Widget Logic statement? I tried to experiment with one of the examples provided in the plugin description (is_category() && in_array($cat, get_term_children( 5, ‘category’))) but it doesn’t seem to work.

    Any help would be greatly appreciated and thank you in advance.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Logic code for a parent category and all its subcategories in Woocommerce’ is closed to new replies.