add_filter('woocommerce_get_breadcrumb', function($crumbs, $breadcrumb){ if (!is_product()) { return $crumbs; } global $product; $terms = get_the_terms($product->get_id(), 'product_cat'); if (!$terms || is_wp_error($terms)) { return $crumbs; } $deepest = null; $max_depth = -1; foreach ($terms as $term) { $depth = count(get_ancestors($term->term_id, 'product_cat')); if ($depth > $max_depth) { $max_depth = $depth; $deepest = $term; } } $new_crumbs = [ $crumbs[0], // Domov ]; $ancestors = array_reverse( get_ancestors($deepest->term_id, 'product_cat') ); foreach ($ancestors as $ancestor_id) { $ancestor = get_term($ancestor_id, 'product_cat'); $new_crumbs[] = [ $ancestor->name, get_term_link($ancestor) ]; } $new_crumbs[] = [ $deepest->name, get_term_link($deepest) ]; return $new_crumbs; }, 10, 2);