Remove breadcrumbs from WooCommerce Storefront theme

你说的曾经没有我的故事 提交于 2019-12-08 06:45:12

问题


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?


回答1:


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);
}



回答2:


since Storefront 2.3.1 try this

add_action('init', 'dp_remove_wc_breadcrumbs');

function dp_remove_wc_breadcrumbs(){
    remove_action('storefront_before_content', 'woocommerce_breadcrumb', 10);
};



回答3:


Try this:

add_filter( ‘woocommerce_get_breadcrumb’, ‘__return_false’ );
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);



回答4:


.breadcrumb{
     display: none;
}


来源:https://stackoverflow.com/questions/45118245/remove-breadcrumbs-from-woocommerce-storefront-theme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!