从WooCommerce店面主题中删除面包屑 [英] Remove breadcrumbs from WooCommerce Storefront theme
问题描述
为了从店面主题中删除面包屑,请文档指出要在functions.php
中添加以下内容:
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
我在Storefront的子主题中尝试了此操作,但它不起作用.追溯woocommerce_breadcrumb
,它似乎已添加到storefront_content_top
动作中(在文件<storefront_dir>/inc/woocommerce/storefront-woocommerce-template-hooks.php
中.我注释掉了相应的行,并且确实隐藏了面包屑.
但是,为了正确执行此操作,我尝试使用
将其从子主题中禁用remove_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
但是它不起作用.我需要澄清的是,我在没有其他代码的情况下以全新的子主题进行了测试.
如何禁用子主题的面包屑?
将以下代码段复制并粘贴到您的functions.php文件中.
add_action( 'init', 'z_remove_wc_breadcrumbs');
function z_remove_wc_breadcrumbs() {
remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10);
}
In order to remove breadcrumbs from the Storefront theme, the documentation states to add the following in functions.php
:
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
I tried this in a child theme of Storefront and it doesn't work. Tracing back the woocommerce_breadcrumb
, it seems to be added in storefront_content_top
action (in the file <storefront_dir>/inc/woocommerce/storefront-woocommerce-template-hooks.php
. I commented out the corresponding line and indeed the breadcrumbs are hidden.
However, to do this the right way, I try to disable it from the child theme using
remove_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
but it doesn't work. I should clarify that I test this in a fresh child theme with no other code.
How would one disable the breadcrumbs from a child theme?
Copy and paste the following snippet into your functions.php file.
add_action( 'init', 'z_remove_wc_breadcrumbs');
function z_remove_wc_breadcrumbs() {
remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10);
}
这篇关于从WooCommerce店面主题中删除面包屑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!