2017-03-01 249 views
0

在我的產品模板,我執行這個動作:編輯產品掛鉤Woocommerce

<?php 
    /** 
    * woocommerce_single_product_summary hook. 
    * 
    * @hooked woocommerce_template_single_title - 5 
    * @hooked woocommerce_template_single_rating - 10 
    * @hooked woocommerce_template_single_price - 10 
    * @hooked woocommerce_template_single_excerpt - 20 
    * @hooked woocommerce_template_single_add_to_cart - 30 
    * @hooked woocommerce_template_single_meta - 40 
    * @hooked woocommerce_template_single_sharing - 50 
    */ 
    do_action('woocommerce_single_product_summary'); 
?> 

我想是編輯woocommerce_template_single_excerpt所以我的functions.php寫了這個代碼:

add_action('woocommerce_template_single_excerpt', 'woocommerce_custom_single_excerpt', 20); 

function woocommerce_custom_single_excerpt() { 
    global $post; 
    echo '<p class="product-description">'; 
    echo $post->post_excerpt; 
    echo '</p>'; 
} 

但它根本不覆蓋。

感謝您的幫助!

回答

2

請嘗試此代碼片段。

add_action('woocommerce_single_product_summary', 'woocommerce_custom_single_excerpt', 15); 

function woocommerce_custom_single_excerpt() { 
    global $post; 
    echo '<p class="product-description">'; 
    echo "hello"; 
    echo '</p>'; 
}