N
N
Nikolay S.2016-04-15 16:24:25
WordPress
Nikolay S., 2016-04-15 16:24:25

How to create separate template for Woocommerce parent category?

Is there something like wc_is_parent_category()?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kozlov, 2016-04-15
@Nikolays93

Get all categories of product taxonomy.
More or less like this:

$terms = get_terms( array(
    'taxonomy' => 'product',
    'hide_empty' => false,
) );

Go through the foreach list and see who has parent == 0. If parent == 0 then add id to the array of parent categories.
After the end of the loop, you will have an array with all parent categories.
Did I understand the question correctly?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question