Updates, Tips & Tricks

Updates as Released, Plus My Personal Collection Of WordPress Best Practices

Customize the WooCommerce Breadcrumb HTML Markup

03 April

The easiest way to do this is to override the woocommerce_breadcrumb function. Add something like the following to your functions.php (obviously add whatever changes you want to make to the markup in the appropriate places):

// Customize the WooCommerce breadcrumb
if ( ! function_exists( 'woocommerce_breadcrumb' ) ) {
    function woocommerce_breadcrumb( $args = array() ) {

        $defaults = array(
            'delimiter'  => '<span class="divider">Delimiter</span>',
            'wrap_before'  => '<ul class="breadcrumb visible-desktop">',
            'wrap_after' => '</ul>',
            'before'   => '<li>',
            'after'   => '</li>',
            'home'    => null
        );

        $args = wp_parse_args( $args, $defaults  );
        // Don't display on product single page
        if (is_singular('product')) { } else {
            woocommerce_get_template( 'shop/breadcrumb.php', $args );
        }
    }
}
No comments yet.

Leave a Reply