Remove pagination trails from WooCommerce Breadcrumb

Today i am sharing small snippet that removes Pagination Trail from WooCommerce breadcrumbs.

Some shop owners may dislike this built-in feature and would like remove WooCommerce pagination links from WooCommerce navigation breadcrumb.

First let’s see how is before-after state of this change.

Before:

After:

Now let’s write a snippet for that:

add_filter('woocommerce_get_breadcrumb',function($crumbs,$tthis){
    if(strpos($crumbs[count($crumbs)-1][0],'Page ')===0){
        unset($crumbs[count($crumbs)-1]);
        $args["breadcrumb"][count($crumbs)-1][1]='';
    }
    return $crumbs;
},10,2);

What this snippet does is simple, it gets generated crumbs from WooCommerce breadcrumb hook, checks if its last element contains pagination trail, and if yes, it removes that part from generated array. And a a result we get the same breadcrumb that the first page has.

Update: if your website is not in English, then don’t forget to change “Page ” string on the line 2 to the corresponding string in your language.

Get more useful WP tricks and snippets by subscribing to my mailclub.

18 Replies to “Remove pagination trails from WooCommerce Breadcrumb”

  1. Thank you .. it works .. just a note .. There is a word “Page”, I had to translate it to our language/translation .. it is not working if you have a translation 😉
    add_filter(‘woocommerce_get_breadcrumb’,function($crumbs,$tthis){
    if(strpos($crumbs[count($crumbs)-1][0],’Stran ‘)===0){
    unset($crumbs[count($crumbs)-1]);
    $args[“breadcrumb”][count($crumbs)-1][1]=”;
    }
    return $crumbs;
    },10,2);

    1. Hi Gregor. If you can share the URL, i can check it. Or you can contact me.
      I guess there might be some different letter or symbol which doesn’t let your code working.

    1. Yes, in this case you need to replace Page with برگه

      So replace this line
      if(strpos($crumbs[count($crumbs)-1][0],’Page ‘)===0){

      with

      if(strpos($crumbs[count($crumbs)-1][0],’برگه’)===0){

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.