2017-09-23 137 views

回答

0

Woocommerce已經顯示評論數旁邊星級單品頁。但在商店和檔案頁面上,它只顯示星級評分。即使在商店和檔案頁面上,按照以下步驟顯示星級評分。

步驟1)創建你的主題的根一個新的文件夾並將其命名爲「woocommerce」

步驟2)在新創建的「woocommerce」文件夾並將其命名爲「環」

創建一個新的文件夾步驟3)添加「rating.php」文件到新創建的「迴路」文件夾

現在你的目錄會是這個樣子

/的public_html /可溼性粉劑內容/主題/你的主題/ woocommerce /循環

下面的代碼添加到新創建的「rating.php」,並根據您的需要進行定製。

<?php 
/** 
* Loop Rating 
* 
* This template can be overridden by copying it to yourtheme/woocommerce/loop/rating.php. 
* 
* HOWEVER, on occasion WooCommerce will need to update template files and you 
* (the theme developer) will need to copy the new files to your theme to 
* maintain compatibility. We try to do this as little as possible, but it does 
* happen. When this occurs the version of the template file will be bumped and 
* the readme will list any important changes. 
* 
* @see   https://docs.woocommerce.com/document/template-structure/ 
* @author  WooThemes 
* @package  WooCommerce/Templates 
* @version  3.0.0 
*/ 

if (! defined('ABSPATH')) { 
    exit; 
} 

global $product; 

if (get_option('woocommerce_enable_review_rating') === 'no') { 
    return; 
} 

$rating_count = $product->get_rating_count(); 
$review_count = $product->get_review_count(); 
$average  = $product->get_average_rating(); 

if ($rating_count >= 0) : ?> 

      <?php echo wc_get_rating_html($average, $rating_count); ?> 
     <?php if (comments_open()): ?><a href="<?php echo get_permalink() ?>#reviews" class="woocommerce-review-link" rel="nofollow">(<?php printf(_n('%s',$review_count,'woocommerce'), '<span class="count">' . esc_html($review_count) . '</span>'); ?>)</a><?php endif ?> 


<?php endif; ?> 

在這種情況下,不「woocommerce」文件夾工作

添加「模板」文件夾,然後在「模板」文件夾中添加「迴路」文件夾中。

現在的目錄應該是這樣

/的public_html /可溼性粉劑內容/主題/你的主題/ woocommerce /模板/循環