【问题标题】:WooCommerce product reviews not showing in product detail pageWooCommerce 产品评论未显示在产品详细信息页面中
【发布时间】:2019-06-02 20:59:34
【问题描述】:

我开发了一个非常基本的 WordPress 主题并安装了 WooCommerce。 WooCommerce 的每个功能都在我的主题中完美运行。

问题:仅在产品详情页、产品评论标签、评论列表和评论表单中丢失。

在 WooCommerce 设置下启用评论设置,在 WordPress 中默认讨论设置也启用。

对于产品详细信息页面,我使用带有以下代码的“single-product.php”模板。

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title();?></h2>
<?php the_content();?>
<?php endwhile; endif; ?>

注意:当我在 functions.php 中添加以下内容时,整个商店和 WooCommerce 都会停止工作,一切都会被扭曲。

add_theme_support( 'woocommerce' );

请建议如何解决此问题。

【问题讨论】:

  • 第一个问题,当 woocomerce 有其他代码时,为什么要使用上述代码?
  • 在不使用“add_theme_support()”的情况下启用评论是否幸运?

标签: wordpress woocommerce hook-woocommerce woocommerce-theming


【解决方案1】:

您需要添加此功能并检查评论是否启用? 按照这个链接 https://github.com/woocommerce/woocommerce/wiki/Declaring-WooCommerce-support-in-themes

  function mytheme_add_woocommerce_support() {
  add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );

【讨论】:

  • 我已经尝试过这个功能,添加它会扭曲我的 WooCommerce 商店的所有内容,然后我无法访问产品详细信息页面。
  • 禁用 cmets 将隐藏产品页面上的评论表单
【解决方案2】:

如果您已经完美地完成了代码,但请不要忘记产品管理员端的启用评论选项。

这里我已经解释了步骤供您参考。 在管理端产品数据 -> 高级 -> 启用评论

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多