• Resolved frankmarks

    (@frankmarks)


    I want to make the very last Woocommerce shop breadcrumb element on each shop page a h1 header, e.g. the Word “Biking” in the following example:

    Startpage > SHOP > Sports > Biking

    I have already found the following code which allows to make several changes to the breadcrumb settings:

    add_filter( 'woocommerce_breadcrumb_defaults', 'jk_woocommerce_breadcrumbs' );
    function jk_woocommerce_breadcrumbs() {
        return array(
                'delimiter'   => ' / ',
                'wrap_before' => '<nav class="woocommerce-breadcrumb" itemprop="breadcrumb">',
                'wrap_after'  => '</nav>',
                'before'      => '',
                'after'       => '',
                'home'        => _x( 'Home', 'breadcrumb', 'woocommerce' ),
            );
    }

    What I don’t know is how to add the h1 heading so that it is solely assigned to the last element (I do not want the whole breadcrumb be h1, just the last element).

    I am grateful for your support – Thanks!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Take a look at the following template, line 34

    https://github.com/woocommerce/woocommerce/blob/3.8.0/templates/global/breadcrumb.php#L34

    * This template can be overridden by copying it to yourtheme/woocommerce/global/breadcrumb.php.

    Replace that code line

    echo esc_html( $crumb[0] );

    With

    echo '<h1>' . esc_html( $crumb[0] ) . '</h1>';

    How to Edit Files Edit files in an upgrade-safe way using overrides. Copy the template into a directory within your theme named /woocommerce keeping the same file structure but removing the /templates/ subdirectory.

    Example: To override the admin order notification, copy: wp-content/plugins/woocommerce/templates/emails/admin-new-order.php to wp-content/themes/yourtheme/woocommerce/emails/admin-new-order.php

    The copied file will now override the WooCommerce default template file.

    Thread Starter frankmarks

    (@frankmarks)

    Dear crslz,

    Thank you so much for the anwer above, I already implemented it in my child-theme and it works just great!!
    Appreciate your help.

    Best regards.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to make the last breadcrumb element a H1 heading?’ is closed to new replies.