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.

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

4 Replies to “Remove pagination trails from WooCommerce Breadcrumb”

Leave a Reply

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