【问题标题】:Edit product hook WooCommerce编辑产品挂钩 WooCommerce
【发布时间】:2022-04-27 04:03:32
【问题描述】:

在我的产品模板上,我执行此操作:

<?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>';
}

但它根本不会覆盖。

感谢您的帮助!

【问题讨论】:

    标签: php wordpress woocommerce product hook-woocommerce


    【解决方案1】:

    请试试这个代码sn-p。

    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>';
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-21
      • 2021-07-10
      • 2021-06-09
      • 2021-12-03
      • 2018-12-06
      • 1970-01-01
      • 2017-07-02
      相关资源
      最近更新 更多