Skip to content

Instantly share code, notes, and snippets.

@warrendholmes
Created July 18, 2012 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warrendholmes/3135463 to your computer and use it in GitHub Desktop.
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
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