Reputation: 151
I am trying to remove the breadcrumbs from my shop, category and tag pages. But nothing works.
add_filter( 'woocommerce_before_main_content', 'remove_breadcrumbs');
function remove_breadcrumbs() {
if(!is_product()) {
remove_action(
'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
}
}
Wanted to start from here but I don't know what is missing.
Upvotes: 2
Views: 11891
Reputation: 9373
By CSS you can do like:
.woocommerce-page section#title {
display: none;
}
Removing breadcrumbs with CSS is not the right solution, cause it still on the page (but hidden) and takes some time on page loading.
Find functions.php in your active theme folder and add this code at the end of the file:
// Remove breadcrumbs from shop & categories
add_filter( 'woocommerce_before_main_content', 'remove_breadcrumbs');
function remove_breadcrumbs() {
if(!is_product()) {
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
}
}
Using WooCommerce Conditional Tags we can build own logic. For example, code above is removing breadcrumbs on shop and categories pages, but leave it on the single product page.
You can remove breadcrumbs on the shop page, but leave it in categories:
// Remove breadcrumbs only from shop page
add_filter( 'woocommerce_before_main_content', 'remove_breadcrumbs');
function remove_breadcrumbs() {
if(!is_product() && !is_product_category()) {
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
}
}
Or you can also remove by page id or page slug:
add_action('template_redirect', 'remove_page_breadcrumbs' );
function remove_page_breadcrumbs(){
if (is_page('YOUR_PAGE_ID_OR_SLUG'))
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
}
Upvotes: 8