最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Woocommerce woocommerce_breadcrumb_defaults filter

programmeradmin0浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 years ago.

Improve this question

i was just struggle for hours now trying to deal with the breadcrumb of woocommerce, I just saw that with a normal function it doesnt work..

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' ),
    );
}

but the closure one bellow works

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' ),
    );
} );

Anyone can explain why it doesnt work or where i failed?

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 5 years ago.

Improve this question

i was just struggle for hours now trying to deal with the breadcrumb of woocommerce, I just saw that with a normal function it doesnt work..

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' ),
    );
}

but the closure one bellow works

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' ),
    );
} );

Anyone can explain why it doesnt work or where i failed?

Share Improve this question asked Feb 13, 2020 at 19:42 Jonathan V.Jonathan V. 11 bronze badge 1
  • The only reason the first one wouldn't work, if the second one does, is if there's already a function called custom_breadcrumb() somewhere on your site. Try changing it to something more unique, to see if that helps. – Jacob Peattie Commented Feb 14, 2020 at 16:08
Add a comment  | 

1 Answer 1

Reset to default 0

My bad.. it was the namespace

add_filter( 'woocommerce_breadcrumb_defaults', 'mynamespace\\custom_breadcrumb');
发布评论

评论列表(0)

  1. 暂无评论