carasmo
1/27/2016 - 7:51 PM

For Genesis Child Theme (or any child theme, or change the path on the load_template if a parent theme). These instructions will help you sh

For Genesis Child Theme (or any child theme, or change the path on the load_template if a parent theme). These instructions will help you show a different single product template page based on the category slug. If this was helpful, saved you hours of time, please consider a small donation via PayPal to christinabeymer@gmail.com.

<?php

/** ====================================================================================

 * Return single product template page based on category slug 

==================================================================================== **/


/** ========== Instructions ========================================================

 * If this is helpful, consider a small donation via PayPal to christinabeymer@gmail.com 

 * 1. Copy your existing child-theme/woocommerce/single-product.php and rename it
 *    default-single.php. Do nothing on the default-single.php. 
 *    Put default-single.php in your child-theme/woocommerce/ directory
 
 * 2. Replace the contents of the original single-product.php with the contents of
 *    this gist minus the instructions. Use the correct tools 
 *    for this -- good code editor and ftp or shell access.


==================================================================================== **/


 
global $woocommerce;
 

// 'category-slug' is your slug

if ( has_term( 'category-slug', 'product_cat' ) ) :

    $file = 'woo-test-single.php'; // the category specific template
    
else: // not term show default

    $file = 'default-single.php'; // the default single template 
    
endif;



load_template( get_stylesheet_directory() . '/woocommerce/'.$file );


//genesis(); not required