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

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

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

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

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

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

或者我需要通過(guò)子主題來(lái)做到這一點(diǎn)嗎?一直試圖找到用于描述的鉤子,但只能找到一個(gè)用于簡(jiǎ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:

這是說(shuō)明.

只是一些示例文本來(lái)填寫說(shuō)明.

Just some sample text to fill the description out.

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

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

這是說(shuō)明.

只是一些示例文本來(lái)填寫說(shuō)明.

Just some sample text to fill the description out.

這是描述的最后一行

我在簡(jiǎn)短描述之前注入文本的代碼是這樣的:

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

推薦答案

你可以使用這個(gè)鉤在 the_content 過(guò)濾器鉤子中的自定義函數(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;
}

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

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

添加 - 為空時(shí)強(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;
}

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

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

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

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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)證問(wèn)題中添加自定義注冊(cè)字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡(jiǎn)單產(chǎn)品中添加一個(gè)將更改價(jià)格的選擇字段)
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毛片| 99在线免费视频 | 91日韩在线 | 欧美日韩久久久久 | 亚洲成人一区二区三区 | caoporn免费| 国产一区在线看 | 亚洲国产精品久久久久婷婷老年 | 精品免费国产视频 | 91精品国产综合久久久久 | 操人网站 | 四色永久| 国产伦精品 | 99福利视频导航 | 天堂一区 | 中文字幕 国产精品 | 精品一区二区三区在线视频 | 亚洲日本中文 | 99久久精品一区二区毛片吞精 | 日韩欧美国产精品综合嫩v 一区中文字幕 | 久久国内 | 欧美日韩亚洲视频 | 免费毛片在线 | 羞视频在线观看 | 成人久久18免费网站 | 欧美精品久久 | 精久久久久 | 色一级片| 狠狠插天天干 | 999久久久久久久久 国产欧美在线观看 | 久久久国产一区二区三区 | av男人的天堂av | 2020国产在线 | 中文字幕免费在线 | 日韩成人av在线播放 | 国产午夜精品理论片a大结局 | 色片在线观看 |