Disabling the Customizr’s breadcrumb on some pages

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.

 

5 thoughts on “Disabling the Customizr’s breadcrumb on some pages”

Comments are closed.