Skip to content
Advertisement

Woocommerce rating not showing in new custom theme

I am working on to new custom theme. I have installed woocommerce plugin. I have import product from xml files. I had tried to test rating functionality. Its working on wordpress default theme twentytwelve, twentysixteen. etc. But when I switched to my custom theme. comment section not showing rating.

Take a look on screenshot. Comment section has only textarea.

Here is my code of comments.php

<div class="comments">
    <?php if (post_password_required()) : ?>
    <p><?php _e( 'Post is password protected. Enter the password to view any comments.', 'html5blank' ); ?></p>
</div>

    <?php return; endif; ?>

<?php if (have_comments()) : ?>

    <h2><?php comments_number(); ?></h2>

    <ul>
        <?php wp_list_comments('type=comment&callback=html5blankcomments'); // Custom callback in functions.php ?>
    </ul>

<?php elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) : ?>

    <p><?php _e( 'Comments are closed here.', 'html5blank' ); ?></p>

<?php endif; ?>

<?php comment_form(); ?>

</div>

my screenshot

Advertisement

Answer

You might need to declare WooCommerce support if you are using custom theme in order to make it compatible with WooCommerce. Default WordPress themes would be normally compatible with WooCommerce and they will work without adding anything. You can read more here – https://woocommerce.com/document/third-party-theme-compatibility/.

Step 1: Add this to your theme’s ‘functions.php’.

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

Step 2: If still reviews not showing, copy your theme’s ‘page.php’ as ‘woocommerce.php’. Remove the loop – <?php if(have_posts()): while(have_posts()): the_post(); ?> and <?php endwhile; endif; ?>. Replace the_content() with woocommerce_content().

Let me know whether these fixes the issue, else paste new ‘woocommerce.php’ contents in your question.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement