久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

將自定義內(nèi)容添加到 WooCommerce 產(chǎn)品描述

Add custom content to WooCommerce product description(將自定義內(nèi)容添加到 WooCommerce 產(chǎn)品描述)
本文介紹了將自定義內(nèi)容添加到 WooCommerce 產(chǎn)品描述的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我正在嘗試在我的描述結(jié)尾插入一些文本.可以用過濾器嗎?

I'm trying to inject some text in my description ending. Is it possible with filter?

或者我需要通過子主題來做到這一點(diǎn)嗎?一直試圖找到用于描述的鉤子,但只能找到一個用于簡短描述的鉤子.示例:

Or do i need to do this via child theme? Been trying to find the hook for description but can only find one for short description. Example:

這是說明.

只是一些示例文本來填寫說明.

Just some sample text to fill the description out.

我想要的是注入這是描述中的最后一行"所以孔描述看起來像這樣.

What i want is to inject "This is the last line in the description" So the hole description would look like this.

這是說明.

只是一些示例文本來填寫說明.

Just some sample text to fill the description out.

這是描述的最后一行

我在簡短描述之前注入文本的代碼是這樣的:

The code i have for injecting text before short description is this:

add_filter( 'woocommerce_short_description', 'single_product_short_descriptions', 10, 1 );
function single_product_short_descriptions( $post_excerpt ){
    global $product;

    if ( is_single( $product->id ) )
        $post_excerpt = '<div class="product-message"><p>' . __( "Article only available in the store.", "woocommerce" ) . '</p></div>' . $post_excerpt;

    return $post_excerpt;
}

推薦答案

你可以使用這個鉤在 the_content 過濾器鉤子中的自定義函數(shù):

You can use this custom function hooked in the_content filter hook this way:

add_filter( 'the_content', 'customizing_woocommerce_description' );
function customizing_woocommerce_description( $content ) {

    // Only for single product pages (woocommerce)
    if ( is_product() ) {

        // The custom content
        $custom_content = '<p class="custom-content">' . __("This is the last line in the description", "woocommerce").'</p>';

        // Inserting the custom content at the end
        $content .= $custom_content;
    }
    return $content;
}

代碼位于活動子主題(或活動主題)的 functions.php 文件中.經(jīng)測試有效.

Code goes in functions.php file of your active child theme (or active theme). Tested and works.

添加 - 為空時強(qiáng)制產(chǎn)品描述(如果您希望顯示此自定義文本):

Addition - Force product description when is empty (if you want this custom text to be displayed):

add_filter( 'woocommerce_product_tabs', 'force_description_product_tabs' );
function force_description_product_tabs( $tabs ) {

    $tabs['description'] = array(
        'title'    => __( 'Description', 'woocommerce' ),
        'priority' => 10,
        'callback' => 'woocommerce_product_description_tab',
    );

    return $tabs;
}

代碼位于活動子主題(或活動主題)的 function.php 文件中.經(jīng)測試有效.

Code goes in function.php file of your active child theme (or active theme). Tested and works.

這篇關(guān)于將自定義內(nèi)容添加到 WooCommerce 產(chǎn)品描述的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產(chǎn)品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產(chǎn)品的總訂單數(shù))
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗(yàn)證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產(chǎn)品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產(chǎn)品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結(jié)帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 久久久久久久久久久国产 | 懂色av一区二区三区 | 欧美精品亚洲 | 999在线视频 | 天天草天天 | 天天干天天做 | 97人人草 | 二区三区视频 | 亚洲精品不卡 | 亚洲二区视频 | 久操福利| 天天插天天狠天天透 | 老女人性生活视频 | 在线播放一区 | 成人国产精品久久久网站 | av在线播放不卡 | 日韩一区在线播放 | 97在线视频观看 | 深夜福利视频网站 | 日韩不卡在线 | 国产又粗又猛又黄又爽无遮挡 | 日韩视频在线观看免费 | 精品视频一区二区三区 | 四虎影音| 日韩一区精品 | 91网站免费| 国产理论在线观看 | 青青草国产精品 | 黄色片免费观看 | 黄色大片在线 | 色综合天天综合网国产成人网 | 久久久亚洲一区 | 玖草在线 | 51成人网 | 亚洲精彩视频 | av看片| 亚洲毛片网 | 深夜福利网 | 久青草视频 | 欧美一级欧美三级在线观看 | 欧美视频一二三区 |