显示分隔符的一种更简洁的方法是CSS边框(如Aibrean 建议)。但您可以根据需要设置过滤器:
add_filter( \'woocommerce_breadcrumb_defaults\', \'custom_woocommerce_breadcrumbs\' );
function custom_woocommerce_breadcrumbs() {
return array(
\'delimiter\' => \'<li class="separator"> | </li>\',
\'wrap_before\' => \'<div><ul class="crumbs">\',
\'wrap_after\' => \'</ul></div>\',
\'before\' => \'<li>\',
\'after\' => \'</li>\',
\'home\' => _x( \'Home\', \'breadcrumb\', \'woocommerce\' ),
);
}
更新:为了保持HTML标记的干净性和语义,您可以将分隔符留空,如下所示:
add_filter( \'woocommerce_breadcrumb_defaults\', \'custom_woocommerce_breadcrumbs\' );
function custom_woocommerce_breadcrumbs() {
return array(
\'delimiter\' => \'\', // no delimiter
\'wrap_before\' => \'<div><ul class="crumbs">\',
\'wrap_after\' => \'</ul></div>\',
\'before\' => \'<li>\',
\'after\' => \'</li>\',
\'home\' => _x( \'Home\', \'breadcrumb\', \'woocommerce\' ),
);
}
并在
style.css
:
.crumbs li {
padding: 10px;
border-right: 1px solid black;
}
.crumbs li:last-child {
border-right: none;
}