How to set a custom breadcrumb delimiter in WooCommerce?

Home » Blog » WordPress Development » How to set a custom breadcrumb delimiter in WooCommerce?

Are you looking to customize the breadcrumb navigation on your WooCommerce store? One aspect you might want to change is the delimiter, which is the character or string that separates the different sections of the breadcrumb trail.

By default, WooCommerce uses the / character as the delimiter, but it is possible to change it to any other character or string of your choice.

add_filter( 'woocommerce_breadcrumb_defaults', 'wpturbo_change_breadcrumb_delimiter' );
function wpturbo_change_breadcrumb_delimiter( $defaults ) {
    // Change the breadcrumb delimeter from '/' to '>'
    $defaults['delimiter'] = ' > ';
    return $defaults;
}

This snippet uses the woocommerce_breadcrumb_defaults filter to change the default delimiter from ' / ' to ' > ' in the breadcrumb trail. You can replace ” > ” with any other character or string to use as a delimiter.

Leave a Reply

Your email address will not be published. Required fields are marked *


Sign up to save your WordPress snippets on WPTurbo.