Php 从Woocommerce单一产品审查标题中删除产品标题
我试图在function.PHP文件中使用PHP,在产品收到评论之前/之后,将产品标题从产品页面上的Woocommerce评论标题中删除 当前,默认的商业评论标题如下所示:Php 从Woocommerce单一产品审查标题中删除产品标题,php,wordpress,woocommerce,hook-woocommerce,Php,Wordpress,Woocommerce,Hook Woocommerce,我试图在function.PHP文件中使用PHP,在产品收到评论之前/之后,将产品标题从产品页面上的Woocommerce评论标题中删除 当前,默认的商业评论标题如下所示: (在任何审查之前):首先审查[产品名称] (任何审查后):1次审查[产品名称] 我如何才能将产品标题从任何一个实例中删除,并简单地将产品审查标题更改为静态“创建审查”,而不管是否有审查 我相信这一切都发生在single-products-reviews.php中。不幸的是,我对PHP的了解还不够透彻。如果你的主题没有wo
- (在任何审查之前):首先审查[产品名称]
- (任何审查后):1次审查[产品名称]
我相信这一切都发生在single-products-reviews.php中。不幸的是,我对PHP的了解还不够透彻。如果你的主题没有woocommerce文件夹,你需要将single-product-reviews.PHP从wp-contents/plugins/woocommerce/templates/复制到wp-content/themes/youractivetheme/woocommerce/single-product-reviews.PHP,并将该文件粘贴到该文件夹中。这不会覆盖下一次更新时的更改 请注意,如果您使用的是一些专业主题或非定制开发的主题,那么请使用child-theme(在这里您可以了解有关child-theme的更多信息),然后遵循您的childtheme/woocommerce/single-product.reviews.php文件的目录结构
add_filter("woocommerce_reviews_title", function( $reviews_title, $count, $product )
{
return $reviews_title = esc_html( 'Create a review', 'woocommerce' );
});
一旦你复制到那里,你需要编辑该文件。转到第34行并替换以下代码
$reviews_title = sprintf( esc_html( _n( '%1$s review for %2$s', '%1$s reviews for %2$s', $count, 'woocommerce' ) ), esc_html( $count ), '<span>' . get_the_title() . '</span>' );
或者可以在活动主题的functions.php文件中使用woocommerce\u reviews\u title过滤器
add_filter("woocommerce_reviews_title", function( $reviews_title, $count, $product )
{
return $reviews_title = esc_html( 'Create a review', 'woocommerce' );
});
现在进行更改,首先查看[产品名称]更改以下代码[第75行]
与
这应该对你有用
'title_reply' => have_comments() ? esc_html__( 'Add a review', 'woocommerce' ) : sprintf( esc_html__( 'Be the first to review “%s”', 'woocommerce' ), get_the_title() ),
'title_reply' => have_comments() ? esc_html__( 'Create a review', 'woocommerce' ) : esc_html__( 'Create a review', 'woocommerce' ),