• Resolved Josh

    (@jmccallweb)


    Any idea why the following would have stopped working with the most recent Woo updates? We use a custom template for products within a certain category. This was working fine as recently as Jan. 17.

    add_filter( ‘template_include’, ‘so_25789472_template_include’ );
    function so_25789472_template_include( $template ) {
    if ( is_singular(‘product’) && (has_term( 8, ‘product_cat’)) ) {
    $template = get_stylesheet_directory() . ‘/woocommerce/single-product-issue.php’;
    }
    return $template;
    }

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

    (@jmccallweb)

    Sorry about the bad formatting. Here’s the code again, hopefully prettier.

    add_filter( 'template_include', 'so_25789472_template_include' );
    function so_25789472_template_include( $template ) {
      if ( is_singular('product') && (has_term( 8, 'product_cat')) ) {
        $template = get_stylesheet_directory() . '/woocommerce/single-product-issue.php';
      } 
      return $template;
    }
    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Add a higher priority on the filter. Something above 10.

    If your theme doesn’t declare WC support properly, then it’s possible the new filter in core is coming after yours. Priority above 15 should do the trick.

    • This reply was modified 8 years, 3 months ago by Caleb Burks.
    Thread Starter Josh

    (@jmccallweb)

    That did it. Thanks!

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

The topic ‘Load a custom template for single products’ is closed to new replies.