Dynamic Sidebar for subcategory of a category

Question

I have a site with many product categories and subcategories. I need to show the same sidebar as the primary category in the subcategories as well.

Example:

Wine (sidebar 1)
White Wine (sidebar 1)
Red Wine (sidebar 1)

Distillates (sidebar 2)
Whisky (sidebar 2)
Brandy (sidebar 2)

if ( is_product_category( 'wine' ) ) {
dynamic_sidebar('Wine Sidebar');
}
elseif ( is_product_category( 'distillates' ) ) {
dynamic_sidebar('Distillates Sidebar');
}

This code is only for primary categories.

0
Andrea 2 months 0 Answers 12 views 0

Leave an answer