Wordpress How to Rename the ‘Shop’ Breadcrumb in WooCommerce for Specific Language

How to Rename the ‘Shop’ Breadcrumb in WooCommerce for Specific Language

856
0
woocommerce-breadcrumb

If you have a multilingual WordPress website, and you’re using WooCommerce breadcrumbs, you might want to change the name for your “Shop” page for the different languages.

Here’s how you can solve this

You need to add the below code to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme.

// Rename "Shop" breadcrumb name on RU Shop Page
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' ); //here

foreach($crumbs as $key => $crumb){
if( $target === $crumb[0] && ICL_LANGUAGE_CODE=='ru' ){
// Change name
$crumbs[$key][0] = __( 'You Custom Name Here', 'woocommerce' ); //Write HERE your custom Shop name for Ru language
}
}
return $crumbs;
}

You might also want to rename the Page Title on your different language Shop page.

Here’s how you can rename the page on the shop page

You need to add the below code to your child theme’s functions.php file

// Rename Page title on your Shop page (Rename "Shop" to "Products")
add_filter( 'woocommerce_page_title', 'theme_shop_page_title');

function theme_shop_page_title( $page_title ) {
if( ICL_LANGUAGE_CODE=='ru' && 'Shop' == $page_title) { // Here we chose "Shop" title which we want to rename
return "Products"; // Here goes your custom name for title, i.e. "Products"
}
}

P.S. I’d sure love to hear what you think about this post! Just drop a line in the comment section below and share your thoughts or questions.

Cheers 👋

Previous articleFacebook Automated Rules Guide and Best Practice
Next articleFacebook Ads Campaigns: Complete Guide 2021

LEAVE A REPLY

Please enter your comment!
Please enter your name here

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