爲了從店面主題取出麪包時,documentation國家加入functions.php
如下:取下WooCommerce店面主題麪包屑
remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20);
我在店面的子主題嘗試這樣做,它不工作。追溯woocommerce_breadcrumb
,似乎在storefront_content_top
行動要添加(文件<storefront_dir>/inc/woocommerce/storefront-woocommerce-template-hooks.php
英寸我註釋掉的相應行,確實麪包屑被隱藏。
然而,要做到這一點,正確的方法,我試圖禁用它使用
remove_action('storefront_content_top', 'woocommerce_breadcrumb', 10);
,但它不工作的兒童主題。我要澄清,我沒有其他的代碼測試這個在一個新的子主題。
一個人怎麼會從一個子主題禁用的麪包屑?
請包括一些解釋爲什麼這應該工作。 – Demetris
woocommerce_breadcrumb函數掛鉤到storefront_content_top中,優先級爲10.因此,您必須從storefront_content_top掛鉤中刪除woocommerce_breadcrumb函數。 然後,您必須告訴wordPress何時執行此代碼行,以從storefront_content_top中移除woocommerce_breadcrumb。爲了做到這一點,你需要在函數中插入這一行(在我的例子中是z_remove_wc_breadcrumbs),然後將這個函數掛鉤到wordPress'init'鉤子。因此,只要'init'執行,wordPress就會刪除woocommerce_breadcrumb。 –