woocommerce breadcrump missing shop link [closed]

This can be done a lot easier. It is just necessary to change the permalinks settings accordingly – as mentioned on github at the issue 3145:

Meet this criteria:

// If permalinks contain the shop page in the URI prepend the breadcrumb with shop 
if (
  $shop_page_id
  && strstr( $permalinks['product_base'], "https://wordpress.stackexchange.com/" . $shop_page->post_name )
  && get_option( 'page_on_front' ) !== $shop_page_id
 ) {
   $prepend = $before 
     . '<a href="' . get_permalink( $shop_page ) . '">' 
     . $shop_page->post_title . '</a> ' 
     . $after . $delimiter;
 }

Otherwise its never prepended.

To apply this one has to go to:

→ WordPress Backend → Settings → Permalinks

And set the woocommerce permalinks settings to one of these:

  • Shop Base
  • Shop Base With Category
  • Custom Base

If the latter is used the slug »/shop/…« has to be prepended.

There is an issue 6584:

Warning: preg_match(): Unknown modifier ‘t’ in wc-core-functions.php on line 533

Which for example occures if the »Custom Base« looks like this: »/shop/product/…«. There is a commit that fixed it, which is available in master, but not 2.2.8.

The slug part shop can be replaced by something else too, for example something localized.