所以,你可以使用這種方式:
add_filter('woocommerce_short_description', 'single_product_short_description', 10, 1);
function single_product_short_description($post_excerpt){
global $product;
if (is_single($product->id))
$post_excerpt = '<p class="some-class">' . __("article only available in the store.", "woocommerce") . '</p>';
return $post_excerpt;
}
通常這個代碼將覆蓋現有的簡短的說明文字中的單品頁,如果這個簡短的描述存在...
(更新) - 與您的評論
如果你想DISPLA Y本不重載摘錄(簡短描述),你可以用這種方式之前添加:
add_filter('woocommerce_short_description', 'single_product_short_description', 10, 1);
function single_product_short_description($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;
}
所以,你會之前得到你的消息,後(如果簡短描述存在的話)的簡短說明...
你可以風格這種方式針對您的活動主題style.css
文件中的類選擇.product-message
,例如:
.product-message {
background-color:#eee;
border: solid 1px #666;
padding: 10px;
}
你需要編寫自己的樣式規則得到它,只要你想。
謝謝@LoicTheAztec,但我要求顯示,無需更換任何所著文字的方法。這可能嗎? –
謝謝你的幫助非常@LoicTheAztec,我很感激。但我認爲我的英語不夠好......一位同事找到了解決這個問題的可能辦法。工作好我會讓你知道:) –