Hi,
You might need to disable the built-in Customizr breadcrumb in some contexts of your website.
You can easily unhook the breadcrumb actions by checking the post types, or using the WordPress built-in conditional tags.
Use case : disabling the breadcrumb on the WooCommerce product pages
All product pages
add_action ('wp_head' , 'tc_disable_breadcrumb'); function tc_disable_breadcrumb() { if ( 'product' != get_post_type() || is_search() ) return; remove_action( '__before_main_container' , array( TC_breadcrumb::$instance , 'tc_breadcrumb_display' ), 20 ); }
Product list pages
add_action ('wp_head' , 'tc_disable_breadcrumb'); function tc_disable_breadcrumb() { if ( 'product' != get_post_type() || is_single() || is_search() ) return; remove_action( '__before_main_container' , array( TC_breadcrumb::$instance , 'tc_breadcrumb_display' ), 20 ); }
Product single page
add_action ('wp_head' , 'tc_disable_breadcrumb'); function tc_disable_breadcrumb() { if ( 'product' != get_post_type() || !is_single() || is_search() ) return; remove_action( '__before_main_container' , array( TC_breadcrumb::$instance , 'tc_breadcrumb_display' ), 20 ); }
Where to paste this code? => in your functions.php file. I strongly recommend to create a child theme. Download a start-up child theme here.
Everything you need to know about child theme with Customizr here.
Read How to customize the Customizr WordPress theme? if have never used a functions.php file in a child theme.
6 thoughts on “Disabling the Customizr’s breadcrumb on some pages”
Hi,
For the latest version, use the above code with a small change: Change all instances of TC_breadcrumb to CZR_breadcrumb
Hi, this doesn’t work neither. What are we supposed to use?
Hi! I have added the code to disable breadcrumb on WooCommerce all pages, but in the latest Customizr update, woocommerce pages won’t load so i had to disable it. Can someone help?
Thanks
Could I disable the Customizr’s breadcrumb in a specific page?
Hi, you can use the is_page() conditional tag and get_the_id() to test the page id or even get_page_by_title().
Hope this helps
In case anyone is looking for a solution that works for a template-specific page:
// Hide breadcrumbs on main pages
add_action (‘wp_head’ , ‘tc_disable_breadcrumb’);
function tc_disable_breadcrumb() {
if ( ! is_page_template( ‘custom-page.php’ ) ) //change template
return;
remove_action( ‘__before_main_container’ , array( TC_breadcrumb::$instance , ‘tc_breadcrumb_display’ ), 20 );
}