我刚刚挣扎了几个小时,试图处理woocommerce的面包屑,我只是看到,正常的功能是不起作用的。。
add_filter( \'woocommerce_breadcrumb_defaults\', \'custom_breadcrumb\');
function custom_breadcrumb() {
return array(
\'delimiter\' => \'<li class="mx-2 text-gray-500">/</li>\',
\'wrap_before\' => \'<ol class="breadcrumb flex text-xs uppercase text-gray-400 font-medium">\',
\'wrap_after\' => \'</ol>\',
\'before\' => \'<li class="hover:text-blue-500">\',
\'after\' => \'</li>\',
\'home\' => _x( \'Home\', \'breadcrumb\', \'woocommerce\' ),
);
}
但下面的一句话起作用了
add_filter( \'woocommerce_breadcrumb_defaults\', function() {
return array(
\'delimiter\' => \'<li class="mx-2 text-gray-500">/</li>\',
\'wrap_before\' => \'<ol class="breadcrumb flex text-xs uppercase text-gray-400 font-medium">\',
\'wrap_after\' => \'</ol>\',
\'before\' => \'<li class="hover:text-blue-500">\',
\'after\' => \'</li>\',
\'home\' => _x( \'Home\', \'breadcrumb\', \'woocommerce\' ),
);
} );
任何人都可以解释为什么它不起作用,或者我在哪里失败了?