On a single product page, WooCommerce will display related products from the same category at the bottom.
For that, it uses a default text, which is “Related products”.
Unfortunately, there’s no built-in option to change that text. But, luckily, there’s a solution, and I’ll show it to you!
Change “Related products” Text in WooCommerce
I recommend backing up your functions.php file or the entire website! I also recommend using a child theme, otherwise, all the changes will be lost with the next theme update.
If you don’t have a child theme, you can use the Code Snippets plugin to add the code there.
For this tutorial, I’ll be using the functions.php
file from a child theme and cPanel.
Step 1
You’ll need to access your WordPress site’s files to edit the functions.php
file.
Normally, the file can be found in:
public_html/wp-content/theme/YourThemeName-child/functions.php
Step 2
Add the following code at the very bottom of the file or right above the ?>
ending tag (if there’s any).
// Change WooCommerce "Related products" text
add_filter('gettext', 'change_rp_text', 10, 3);
add_filter('ngettext', 'change_rp_text', 10, 3);
function change_rp_text($translated, $text, $domain)
{
if ($text === 'Related products' && $domain === 'woocommerce') {
$translated = esc_html__('Check out our other products', $domain);
}
return $translated;
}
Final Step
Change the Check out our other products text between the single quotes with whatever text you want.
Leave everything else as is.
The “Related products” text should now be changed.
If the Text Doesn’t Change
1. If you refresh the product page and nothing happens, clear your browser and site cache.
A site’s caching system can come from different (even multiple) places: server, plugins, theme, CDN, page builders.
So, make sure you clear them all until the change appears.
2. Some WordPress themes come with built-in support for WooCommerce.
This means that they might have their own custom code for WooCommerce, which might prevent the above code to work.
In that case, you should consider contacting the theme developers and ask for help.
3. Some plugins might prevent the code to work as well.
If you have any WooCommerce related plugins, disable them, clear the caches, and check the product page.
If you’re using a translation plugin, use that to change the “Related products” text, not the code.
That’s a Wrap
I hope you found this tutorial useful and the solution worked for you!
If you have any questions or thoughts, drop a comment or send a message via contact or Facebook page.
You can also hit the follow button on Twitter and subscribe to the YouTube channel.
Don’t forget to share the post to help out others!
Hello friend,
Thanks for this nice tutorials. It’s very helpful.
Please what if I want to change some other texts on some other pages?
Is there any way I can change them following this same method?
Absolutely Perfect! Thank you so much.
Thanks
Work like a champ!
Thanks so much. Works a treat :)
Hi, that is great. Any ideas how to change the font though? it’s all lower case rather than normal
“products” needs capitalized in later updates of Woocommerce:
if ($text === ‘Related Products’) {