// add back to text function add_back_to_text_before_breadcrumbs($crumbs) { // Check if it's a product category page if (is_product_category()) { // Check if there are at least two breadcrumbs (home and one category) if (count($crumbs) >= 1) { // Get the first breadcrumb (home) $home_breadcrumb = reset($crumbs); // Get the depth of the first category $first_category_depth = $home_breadcrumb[2]['depth']; // Check if it's the first-level category if ($first_category_depth === 0) { // Add "Back to: " before the breadcrumbs array_unshift($crumbs, array('text' => 'Back to: ', 'url' => home_url('/'))); } } } return $crumbs; } add_filter('woocommerce_get_breadcrumb', 'add_back_to_text_before_breadcrumbs', 10, 2);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter