In the members-only forum, a user asked:
I’m trying to show or hide the sidebar using the full-width-content or sidebar-content layout on categories depending on the parent category in WooCommerce.
I have a lot of sub categories so don’t want to do it manually in the archive setting of each category.
I also need to do adjustments for the single products depending on the parent category adding and removing some elements.
In a function hooked to
genesis_pre_get_option_site_layout we can check if the current page is a product category archive and if so, get the current term object and if this term has a specific parent, return
full-width-content (or any other) Genesis layout.
Coming to the second part of the question, in a function hooked to our desired WooCommerce single product location say,
woocommerce_single_product_summary, we can get the terms of the product, loop through each of them and check the term's ID against a specific parent term's ID and if they match, show some special text - as an example of customization to add an element.
Add the following in child theme's functions.php:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Thanks for this Sridhar.
You’re the best, this super helpful!