How To Remove Product Name From Breadcrumbs in Woocommerce

If you need to remove last element from breadcrumbs, you must:

1. In the folder with your theme, create a folders “woocommerce/global”

wp-content/themes/your-theme/woocommerce/global

2. Then copy ffrom Woocommerce plugin (or just create) file “breadcrumbs.php”

wp-content/themes/your-theme/woocommerce/global/breadcrumbs.php

3. Replace (paste) the next code in breadcrumbs.php:

<?php

if ( ! defined( 'ABSPATH' ) ) {
   exit;
}

if ( ! empty( $breadcrumb ) ) {

   echo $wrap_before;

   foreach ( $breadcrumb as $key => $crumb ) {

      echo $before;

      if ( ! empty( $crumb[1] ) && sizeof( $breadcrumb ) !== $key + 1 ) {
         echo '<a href="' . esc_url( $crumb[1] ) . '">' . esc_html( $crumb[0] ) . '</a>';
      } else {
            if(!is_singular()){
                echo esc_html( $crumb[0] );
            }
      }

      echo $after;
        if(sizeof( $breadcrumb ) -2 == $key && (is_singular())){
            continue;
        }

      if ( sizeof( $breadcrumb ) !== $key + 1 ) {
         echo $delimiter;
      }
   }

   echo $wrap_after;

}
How To Delete Last Item From Breadcrumbs in Woocommerce

Last thing, you need to remove the last item in breadcrumbs from the micro data markup. This code placed in functions.php will help:


add_filter('woocommerce_structured_data_breadcrumblist', 'delete_last_item_from_structured_data', 10, 1);

function delete_last_item_from_structured_data($markup){
    if(is_singular()){
        array_pop($markup['itemListElement']);
    }
    return $markup;
}