Reputation: 619
I want to display different design template for my shop Music categories and it's all sub categories compare to other categories design template.
For this i have added following if condition:
if (is_product_category( 'music' ))
{
wc_get_template( 'archive-product-cubicles.php' );
} else
{
wc_get_template( 'archive-product.php' );
}
But above code only display new template for Music parent category not it's child categories.
So any one know solutions for this then please inform me.
Thanks, Ketan.
Upvotes: 1
Views: 2938
Reputation: 777
You can use following:
if (is_product_category( 'music' ) || cat_is_ancestor_of( MUSIC_ID, get_queried_object()->term_id)
{
wc_get_template( 'archive-product-cubicles.php' );
} else
{
wc_get_template( 'archive-product.php' );
}
Replace MUSIC_ID with your own id of music category.
Upvotes: 3