skip to Main Content

I tried to remove the WooCommerce Breadcrumbs with this code:

add_action( 'init', 'remove_wc_breadcrumbs' ); 
function remove_wc_breadcrumbs() { 
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 ); 
}

…which works.

After that I activated the Yoast Seo Plugin Breadcrumbs an placed this code in my theme header.php

<?php if ( function_exists('yoast_breadcrumb') ) {
    yoast_breadcrumb('<p id="breadcrumbs">','</p>');
    } ?>

…which also works.

The problem appears when I navigate to my “shop-site” which I defined in the WooCommerce settings. The full breadcrumb looks like this

Home > Product

Note: The Page name in WordPress for the “shop-site” is “Test” (not “Product”).

I want to override the “Product” in something different. I tried to override it by defining a custom breadcrumb title in the advanced Yoast settings on the wordpress “shop-site” page but it didn’t seems to work. Overriding works if the page isn’t defined as the “shop-site” in the WooCommerce settings. So I guess some function overwrites the Yoast Breadcrumb override but I can’t figure out which function does this.

The same problem appears when I navigate to a single product. Breadcrumb looks like this

Home > Product > Product Name

Again I want to rename the “Product” (only the second crumb here) into something different.

Can someone solve this mysticism?

2

Answers


  1. Chosen as BEST ANSWER

    I fixed it with this code:

    add_filter( 'wpseo_breadcrumb_output', 'custom_wpseo_breadcrumb_output' );
    function custom_wpseo_breadcrumb_output( $output ){
    if( is_product() ){
        $from = 'rel="v:url" property="v:title">Product</a>'; 
        $to = 'rel="v:url" property="v:title">New Title</a>';
        $output = str_replace( $from, $to, $output );
    }
    
    elseif ( is_shop() ) {
        $from = '<span class="breadcrumb_last">Products</span>'; 
        $to = '<span class="breadcrumb_last">New Title</span>';
        $output = str_replace( $from, $to, $output );
    }
    return $output;
    }
    

  2. I wonder if there wouldn’t be an easier way to change the first “product” into sth like “product category”…

    Have you tried in wp-admin:

    1. Go to “Yoast”
    2. Then “SEO settings”
    3. Then “Breadcrumbs” and adapt taxonomies (eg: product > category).
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search