I think the guy in this post is on to something… That post was from 2013 though, and there’s a big difference between our workflows.
I was able to track down the functions he mentioned in class-wc-template-loader.php… can somebody please help me make sense of this and explain how / where to use it?
function comments_template_loader( $template ) {
if ( get_post_type() !== 'product' ) {
return $template;
}
$check_dirs = array(
trailingslashit( get_stylesheet_directory() ) . WC()->template_path(),
trailingslashit( get_template_directory() ) . WC()->template_path(),
trailingslashit( get_stylesheet_directory() ),
trailingslashit( get_template_directory() ),
trailingslashit( WC()->plugin_path() ) . 'templates/',
);
if ( WC_TEMPLATE_DEBUG_MODE ) {
$check_dirs = array( array_pop( $check_dirs ) );
}
foreach ( $check_dirs as $dir ) {
if ( file_exists( trailingslashit( $dir ) . 'single-product-reviews.php' ) ) {
return trailingslashit( $dir ) . 'single-product-reviews.php';
}
}
}
add_filter( 'comments_template', array( __CLASS__, 'comments_template_loader' ) );