是否将Woocommerce评论模板替换为默认评论模板?

是否将Woocommerce评论模板替换为默认评论模板?,woocommerce,comments,review,Woocommerce,Comments,Review,如何删除woocommerce用于评论的评论模板,而默认使用站点评论模板 我编辑了single-product-reviews.php以使其适应网站的评论模板,并使用woocommerce\u product\u review\u comment\u form\u args来适应表单,但我只是想为什么不使用我已有的自定义评论模板呢 编辑:已经达到了成功的方法,但不认为这是最好的 add_action('init', 'mdlr_disable_reviews'); function mdlr_d

如何删除woocommerce用于评论的评论模板,而默认使用站点评论模板

我编辑了single-product-reviews.php以使其适应网站的评论模板,并使用woocommerce\u product\u review\u comment\u form\u args来适应表单,但我只是想为什么不使用我已有的自定义评论模板呢

编辑:已经达到了成功的方法,但不认为这是最好的

add_action('init', 'mdlr_disable_reviews');
function mdlr_disable_reviews() {
remove_filter( 'comments_template', array( WC_Template_Loader::init(),'comments_template_loader' ) );
add_filter( 'comments_template', array( WC_Template_Loader::init(),'mdlr_new_product_comments' )); //need this?
}
//然后在选项卡下禁用评论/评论

add_filter( 'woocommerce_product_tabs', 'mdlr_remove_reviews_tab');
function mdlr_remove_reviews_tab( $tabs ) {
unset( $tabs[ 'reviews' ] );
 return $tabs;
}
//然后我移动了评论/评论

 add_action( 'woocommerce_after_single_product_summary','mdlr_new_product_comments');
 function mdlr_new_product_comments() {
 if ( ! comments_open() ) {
 return;
 }
 comments_template();
 }

只需添加优先级更高的\u过滤器,如下所示:

add_filter( 'comments_template', function() { return '/comments.php'; }, 30 );