問題描述
我正在嘗試在我的描述結尾插入一些文本.可以用過濾器嗎?
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:
推薦答案
你可以使用這個鉤在 the_content
過濾器鉤子中的自定義函數:
You can use this custom function hooked in the_content
filter hook this way:
代碼位于活動子主題(或活動主題)的 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):
代碼位于活動子主題(或活動主題)的 function.php 文件中.經測試有效.
Code goes in function.php file of your active child theme (or active theme). Tested and works.
這篇關于將自定義內容添加到 WooCommerce 產品描述的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!