把阿里巴巴客户信息保存到客户管理

自建WooCommerce里产品详情的短代码

by | Sep 25, 2022 | 建站 | 0 comments

自己定义Woocommerce的产品详描述的短代码, 并应用到需要的地方.

Step1-打开文件

Appearance>>Theme File Editor>>functions.php

Step2-添加代码
function custom_product_description($atts){
    global $product;

    try {
        if( is_a($product, 'WC_Product') ) {
            return wc_format_content( $product->get_description("shortcode") );
        }

        return "Product description shortcode run outside of product context";
    } catch (Exception $e) {
        return "Product description shortcode encountered an exception";
    }
}
add_shortcode( 'custom_product_description', 'custom_product_description' );
Step3-使用代码[custom_product_description]

在Divi主题的模块化编辑器里使用代码, 在你想插入代码的地方>>添加module>>CODE>>填入[custom_product_description]

评论区 —

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *