Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 541
vrajesh Avatar asked Jul 24 '18 11:07

vrajesh


People also ask

How do I display WooCommerce product reviews on a custom page?

Adding the Shortcode php file, we can now use the following shortcode on any page you like; [product_reviews id="ID"] . Simply replace the text ID with the product for which you want to output your customer reviews and that is simply all there is to it!

How do I fix WooCommerce product Review tab not showing on product page?

In the admin area of your store, click on WooCommerce and then Settings. Next, go to settings for products by clicking on Products tab and then choosing General tab. Scroll down to Reviews area where you will see settings for showing product reviews. Make sure that reviews are enabled.

How do I display WooCommerce reviews outside of tabs?

To do this, go to your product page, and click on the “WooCommerce Reviews” tab. From here, you can select the “Add a Review Widget” button. PRO TIP: If you are displaying WooCommerce reviews outside of tabs, be aware that they may not be visible to all users.


1 Answers

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.

like image 96
Outsource WordPress Avatar answered Sep 20 '22 08:09

Outsource WordPress