There are two files you need look around if you want to change your breadcrumb's appearance in WooCommerce. You'll find those files in your WooCommerce plugin directory:
- The first file:
/woocommerce/woocommerce-template.php
, this file contains function definition forwoocommerce_breadcrumb()
if ( ! function_exists( 'woocommerce_breadcrumb' ) ) {
/**
* Output the WooCommerce Breadcrumb
*
* @access public
* @return void
*/
function woocommerce_breadcrumb( $args = array() ) {
$defaults = array(
'delimiter' => ' › ',
'wrap_before' => '<div id="breadcrumb" itemprop="breadcrumb">',
'wrap_after' => '</div>',
'before' => '',
'after' => '',
'home' => null
);
$args = wp_parse_args( $args, $defaults );
woocommerce_get_template( 'shop/breadcrumb.php', $args );
}
}
- The second file:
/woocommerce/templates/shop/breadcrumb.php
, it's the template file for breadcrumb component in WooCommerce. This is the template file that will be called by thewoocommerce_breadcrumb()
function.
If you're going to change it's basic HTML structure such as its wrapper and delimiter, you only need to override the woocommerce_breadcrumb()
function in your functions.php
file. But if you're going to change its whole inner HTML structure, you'll need to override the template function. To do so, you need to copy the /woocommerce/templates/shop/breadcrumb.php
file to /woocommerce/shop/breadcrumb.php
in your theme directory
is there a best practice for overriding the function? currently I'm changing $delimiter to a specific value inside
breadcrumb.php
instead of overridingwoocommerce_breadcrumb()
because I don't understand how.