How to add woocommerce products header title in woocommerce_breadcrumb hook to function.php

Iam new to WooCommerce theming and get stuck with category display page here is the code i have:

/**
 * Change several of the breadcrumb defaults
 */
add_filter('woocommerce_breadcrumb_defaults', 'jk_woocommerce_breadcrumbs');
function jk_woocommerce_breadcrumbs()
{
    if (is_product_category()) {
        global $wp_query;

        // get the query object
        $cat = $wp_query-get_queried_object();

        // get the thumbnail id using the queried category term_id
        $thumbnail_id = get_term_meta($cat-term_id, 'banner', true);

        // get the image URL
        $image = wp_get_attachment_url($thumbnail_id);

        // print the IMG HTML
        echo ;
        return array(
            'delimiter'   = ' #47; ',
            'wrap_before' = 'div class=c-main-banner c-main-banner--inner no-overlay w-100 style=background-image: url(' . $image . 'div class=containerol',
            'wrap_after'  = '/ol/div/div',
            'before'      = 'li',
            'after'       = '/li',
            'home'        = _x('Home', 'breadcrumb', 'woocommerce'),
        );
    }
}


But i need to display like this:

div class=c-main-banner c-main-banner--inner no-overlay w-100 style=background-image: url( category banner image as background );
    div class=container
        ol class=c-breadcrumb
                lia href=breadcrumb slug breadcrumb-name /a/li
        /ol
        div class=c-banner-content d-flex align-items-start justify-content-end flex-wrap flex-column
            big woocommerce-products-header-title /big
        /div
    /div
/div

Topic woocommerce-offtopic breadcrumb hooks Wordpress

Category Web


I am supprised that this question still accepts answers once woocommerce is a plugin and out of the scope of this chat. Anyhow for what I have understood you want to show the product title on the woocommerce breadcrumb, Woocommerce breadcrumb already does that by default, there is no need of any changes, just remove your code. enter image description here

woocommerce_breadcrumb();

If you really want to add to you function the product tittle, you can call it like this

global $product;
echo $product->name;

However this will only works on the product page, on the shop page and like so will not show the product name, or will only show the first product name.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.