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

將自定義內容添加到 WooCommerce 產品描述

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

問題描述

限時送ChatGPT賬號..

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

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

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

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 過濾器鉤子中的自定義函數:

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 文件中.經測試有效.

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

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

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 文件中.經測試有效.

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

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

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

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 免费观看国产视频在线 | 日韩一二三区视频 | 精品视频在线免费观看 | 欧美一区2区三区4区公司 | 伊人亚洲| 99在线播放 | 精品美女视频在线观看免费软件 | 国内精品视频在线观看 | 人人爽人人爽人人片av | 亚洲午夜精品一区二区三区他趣 | 国产一级黄色网 | 日韩在线视频一区 | 亚洲免费网 | 一区二区免费高清视频 | 看一级毛片 | 成人免费在线视频 | www视频在线观看 | 亚洲另类春色偷拍在线观看 | 欧美性生活网 | 久国产视频 | 欧美黑人一级爽快片淫片高清 | 免费av一区二区三区 | 久久久久久久久毛片 | 久久精品国产一区 | 国产精品久久国产精品 | 久久久久国产一区二区三区 | 岛国毛片在线观看 | 欧美精品在线观看 | 夜夜艹天天干 | 国产亚洲精品久久情网 | 欧美日韩精品一区二区三区视频 | 精品亚洲一区二区 | 91精品国产91久久久久久最新 | 亚洲福利av| 国产综合精品一区二区三区 | 免费国产一区 | 日韩成人在线播放 | 一级一级毛片免费看 | 亚洲欧美一区二区三区1000 | 亚洲啪啪 | 国产99久久精品一区二区永久免费 |