Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter iain-g

    (@iain-g)

    Cracked it – in functions.php of my theme:

    if ( ! function_exists( 'woocommerce_content' ) ) {
    	function woocommerce_content() {
    		if ( has_term( 'CATEGORY-NAME', 'product_cat' ) ) {
    			while ( have_posts() ) : the_post();
    				wc_get_template_part( 'content', 'single-product-CATEGORY-NAME' );
    			endwhile;
    		}
    		else {
    			while ( have_posts() ) : the_post();
    				wc_get_template_part( 'content', 'single-product' );
    			endwhile;
    		}
    	}
    }

    Thread Starter iain-g

    (@iain-g)

    OK, talking to myself here, but I’ve added

    if ( ! function_exists( 'woocommerce_content' ) ) {
    	function woocommerce_content() {
    		if ( is_singular( 'product' ) ) {
    			while ( have_posts() ) : the_post();
    				wc_get_template_part( 'content', 'single-product-book' );
    			endwhile;
    		}
    	}
    }

    to my themes functions.php file which works – but how do I target a product category?

    Thread Starter iain-g

    (@iain-g)

    I’ve dug around further, and single-product.php – both my override and the core woo commerce version are ignored – I’ve even deleted them completely. Instead the woocommerce functions.php file sets the template on line 339

    wc_get_template_part( 'content', 'single-product' );

    editing this gets it to look at my template file, though I obviously don’t want to edit that functions file – so how can I override that?

Viewing 3 replies - 1 through 3 (of 3 total)