2017-08-03 40 views

回答

1

感謝上帝發現你的解決方案

你使用的是最新版本的WooCommerce?如果是這樣,看看你的插件文件夾,然後導航到「woocommerce - >模板 - >單品 - > meta.php」。看看第27行,你應該看到至少有一個位置正在創建。嘗試編輯該行,看看它是否適合你。

請記住,任何時候你正在編輯您應該將它們移動到你的主題文件夾中的WooCommerce模板文件。這樣,您仍然可以在不覆蓋編輯的情況下更新WooCommerce。您可以通過覆蓋以安全升級方式編輯這些文件。只需將其複製到名爲/ woocommerce的主題中的目錄中,保留相同的文件結構,但不包括模板文件夾。因此,要覆蓋meta.php文件主題文件夾內的結構將是:woocommerce - >單品 - > meta.php

採取refrence從How to edit what's displayed in the Woocommerce Single Product Meta template?

在我自己的WordPress網站嘗試以及

在上線meta.php 35號替換此

<?php echo wc_get_product_category_list($product->get_id(), ', ', '<span class="posted_in">' . _n('Brand:', 'Brands:', count($product->get_category_ids()), 'woocommerce') . ' ', '</span>'); ?> 

它爲我!乾杯

+0

夥計我看了這個文件5次以上。但直到你提到它才能找到它。感謝兄弟,它像一個魅力。 –

+0

其好的歡呼聲有美好的一天! :) – sagar

0

您可以通過從產品概要取出woocommerce_template_single_meta action從佈局刪除這些,在你的主題functions.php加入...

remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40); 

這將刪除類別又名從佈局產品薈萃。

你可以看到很多這樣的woocommerce鉤在插件woocommerce/includes/wc-template-hooks.php - 我們上面的例子是原本是在這個文件中突出顯示。

/** 
* Product Summary Box 
* 
* @see woocommerce_template_single_title() 
* @see woocommerce_template_single_price() 
* @see woocommerce_template_single_excerpt() 
* @see woocommerce_template_single_meta() 
* @see woocommerce_template_single_sharing() 
*/ 
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5); 
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10); 
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10); 
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20); 
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40); 
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50); 

所以動作包括掛鉤,哪些功能我們鉤住它,並優先號碼 - 所以不是編輯在這裏,你只需簡單地remove_action在functions.php所需的行動,包括優先數,關鍵是找出你需要哪一個!

+0

remove_action('woocommerce_single_product_summary','woocommerce_template_single_meta',40);這是我需要的,但我不知道在哪裏可以找到我的文件! –

+0

將此添加到您主題的functions.php文件中。'remove_action('woocommerce_single_product_summary','woocommerce_template_single_meta',40); ' –

+0

我不需要刪除它,上面有一個CATEGORY部分,我需要將CATEGORY一詞改爲BRAND。 –

相關問題