Функция, которая убирает последний элемент из хлебных крошек в Woocommerce.
Добавляется в файл /wp-content/themes/ВАША ТЕМА/woocommerce/global/breadcrumb.php
Источник: https://gist.github.com/Jany-M/c091959d0c430b865ad7
<?php
if (!defined('ABSPATH')) {
exit;
}
if ($breadcrumb) {
// Point to end of the array
end($breadcrumb);
// Fetch key of the last element of the array
$lastElementKey = key($breadcrumb);
echo $wrap_before;
foreach ($breadcrumb as $key => $crumb) {
// If this is the last element (Product Name) stop iteration
if($key == $lastElementKey) break;
echo $before;
if (!empty($crumb[1]) && sizeof($breadcrumb) !== $key + 1 ) {
?><a href="<?php echo esc_url($crumb[1]); ?>"><?php echo esc_html($crumb[0]); ?></a><?php
} else {
echo esc_html($crumb[0]);
}
echo $after;
// If this is the second last element, then don't print delimiter
if ($key !== $lastElementKey -1 ) {
echo $delimiter;
}
}
echo $wrap_after;
}
?>