@UPDATE1:
試試這個代碼片段功能(無擔保,因爲未經測試),但在邏輯上它應該做的工作(見下面的模板的提取物):
remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20);
或者:
add_action('init', function(){
remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20);
}
首先發現參與該計數功能:woocommerce_result_count()
。
然後,我必須找到相關的掛鉤:
這裏是模板archive-product.php
的提取物了鉤:
<?php
/**
* woocommerce_before_shop_loop hook.
*
* @hooked woocommerce_result_count - 20 <==== ==== ==== ==== Here @@@ !
* @hooked woocommerce_catalog_ordering - 30
*/
do_action('woocommerce_before_shop_loop');
?>
@UPDATE2: - 這也在工作(更新3:替代)
最後一次嘗試基於this old thread (see at the end),壓倒一切的店鋪頁面上的本機功能:
add_action('init', function(){
if(is_shop()){
function woocommerce_result_count(){
return;
}
}
}
或者:
if(is_shop()){
function woocommerce_result_count(){
return;
}
}
@UPDATE3: - 的其他工作解決方案(overri丁模板文件)
功能woocommerce_result_count()
指loop/result-count.php
WooCommerce模板,你可以在此源提取物見:
if (! function_exists('woocommerce_result_count')) {
/**
* Output the result count text (Showing x - x of x results).
*
* @subpackage Loop
*/
function woocommerce_result_count() {
wc_get_template('loop/result-count.php');
}
}
解決辦法:
是:loop/result-count.php
WooCommerce模板,添加:|| is_shop()
到if
聲明(第27行),這種方式:
<?php
/**
* Result Count
*
.../...
* @version 2.0.0
*/
if (! defined('ABSPATH')) {
exit; // Exit if accessed directly
}
global $wp_query;
// @@@ Here we avoid count on shop page <==== ==== ==== ==== ADDING " || is_shop() "…
if (! woocommerce_products_will_display() || is_shop())
return;
/*
.../...
*/
這一工程這個時候......
參考:Overriding Templates via a Theme (+Template Structure)
我知道,這很奇怪。我也嘗試檢查元素,它沒有標籤。這裏是網站,當你可以看到每個產品的標題旁邊的10個庫存http://www.devo.co.uk/product-category/kaycee/ –
你一直非常驚人!我找出了這個問題。我在我的functions.php文件中有一些代碼在所有產品商店頁面上顯示「缺貨」標籤,而不是僅顯示單個產品頁面,這就是問題所在。那麼我現在已經刪除它,但它不完全是我想要的。但你對於你的建議感到驚訝。非常感謝。如果你有興趣,我已經在這裏隔離了真正的問題http://stackoverflow.com/questions/38381969/how-can-i-display-the-out-of-stock-tag-on-the-商店頁面 –