Created
July 18, 2012 10:34
-
-
Save warrendholmes/3135463 to your computer and use it in GitHub Desktop.
Add filter to load a template file for a specific category in WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'template_include', 'woocommerce_add_template_loader_product_category' ); | |
| function woocommerce_add_template_loader_product_category(){ | |
| global $product; | |
| foreach ( get_the_terms( $product->id, 'product_cat' ) as $key => $value) { | |
| locate_template( 'single-product-' . $value->slug . '.php' ,true, $require_once = true) ; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment