1
votes

I tried using this code below to change the URL of the word "Shop" but it seems to do nothing:

add_filter( 'woocommerce_page_title', 'woo_shop_page_title');
function woo_shop_page_title( $page_title ) {
       if( 'Shop' == $page_title) {
              return "My new title";
       }
}

enter image description here

I don't want users to go to the main "Shop" page and setup many categories. Unfortunately I have not been able to find a way to remove or change the URL of that "Shop" breadcrumb. The official docs only mention how to change the "Home" URL, not "Shop".

You're help is appreciated.

3
I think, the breadcrumbs goes from your theme, so should hook to some theme functionSamvel Aleqsanyan

3 Answers

1
votes

To rename any breadcrumb item and change its link, use woocommerce_get_breadcrumb filter hook this way:

add_filter( 'woocommerce_get_breadcrumb', 'custom_get_breadcrumb', 20, 2 );
function custom_get_breadcrumb( $crumbs, $breadcrumb ){
    if( ! is_shop() ) return $crumbs; // Only shop page

    // The Crump item to target
    $target = __( 'Shop', 'woocommerce' );

    foreach($crumbs as $key => $crumb){
        if( $target === $crumb[0] ){
            // 1. Change name
            $crumbs[$key][0] = __( 'Name', 'woocommerce' );

            // 2. Change URL (you can also use get_permalink( $id ) with the post Id
            $crumbs[$key][1] = home_url( '/my-link/' );
        }
    }
    return $crumbs;
}

Code goes in function.php file of your active child theme (or active theme). Tested and works.

0
votes

Please check this code in on home replace Start chenag in woocommerce

function woocommerce_breadcrumb( $args = array() ) { $args = wp_parse_args( $args, apply_filters( 'woocommerce_breadcrumb_defaults', array( 'delimiter' => ' / ', 'wrap_before' => '', 'wrap_after' => '', 'before' => '', 'after' => '', 'home' => _x( 'Home', 'breadcrumb', 'woocommerce' ), ) ) );

    $breadcrumbs = new WC_Breadcrumb();
    $args['home'] = "Start"; // home replace start set
    if ( ! empty( $args['home'] ) ) {
        $breadcrumbs->add_crumb( $args['home'], apply_filters( 'woocommerce_breadcrumb_home_url', home_url() ) );
    }

    $args['breadcrumb'] = $breadcrumbs->generate();
-2
votes

The 'shop' breadcrumb is coming from you 'Shop' pages'. Simply change your shop page slug to whatever you want, or if it is another page altogether then in the woocommerce settings you set the shop page to your new page. The url will always be the page's slug.