首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

在Woocommerce中提交评论后如何显示消息?

在Woocommerce中,提交评论后可以通过以下步骤来显示消息:

  1. 首先,你需要在你的主题文件中找到comments.php文件。这个文件通常位于wp-content/themes/your-theme/comments.php
  2. 打开comments.php文件,找到wp_list_comments()函数的调用。这个函数负责显示评论列表。
  3. wp_list_comments()函数之前,你可以添加以下代码来显示消息:
代码语言:txt
复制
<?php if ( have_comments() ) : ?>
    <h2 class="comments-title">
        <?php
            $comments_number = get_comments_number();
            if ( '1' === $comments_number ) {
                /* 如果只有一个评论 */
                printf( _x( 'One comment', 'comments title', 'textdomain' ) );
            } else {
                /* 如果有多个评论 */
                printf(
                    /* translators: %s: Number of comments */
                    _nx(
                        '%s comment',
                        '%s comments',
                        $comments_number,
                        'comments title',
                        'textdomain'
                    ),
                    number_format_i18n( $comments_number )
                );
            }
        ?>
    </h2>
<?php endif; ?>

<?php if ( have_comments() ) : ?>
    <ol class="comment-list">
        <?php
            wp_list_comments( array(
                'style'      => 'ol',
                'short_ping' => true,
            ) );
        ?>
    </ol>
<?php endif; ?>

<?php
    /* 如果评论被关闭 */
    if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) :
?>
    <p class="no-comments"><?php _e( 'Comments are closed.', 'textdomain' ); ?></p>
<?php endif; ?>

<?php comment_form(); ?>
  1. 保存并上传comments.php文件到你的主题文件夹中。

现在,当用户提交评论后,你将能够在评论列表上方看到一个消息,显示有多少条评论。如果没有评论,将显示相应的提示信息。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

36秒

PS使用教程:如何在Mac版Photoshop中画出对称的图案?

30分14秒

个推TechDay | 如何提升IT资源效率,显著降低IT总投入?

392
1分6秒

PS使用教程:如何在Mac版Photoshop中制作“3D”立体文字?

34秒

PS使用教程:如何在Photoshop中合并可见图层?

1分52秒

Web网页端IM产品RainbowChat-Web的v7.0版已发布

1分10秒

PS小白教程:如何在Photoshop中制作透明玻璃效果?

3分6秒

如何在Mac版Photoshop中去除图片中的水印?

5分33秒

JSP 在线学习系统myeclipse开发mysql数据库web结构java编程

31分41秒

【玩转 WordPress】腾讯云serverless搭建WordPress个人博经验分享

1分23秒

如何平衡DC电源模块的体积和功率?

16分8秒

人工智能新途-用路由器集群模仿神经元集群

领券