How to Change the WooCommerce Related Products Text

In this post we're taking a look at how to change the WooCommerce related products text / title using code added to your functions.php file.

In this article we’re going to take a look at how to change the WooCommerce related products text to something custom that better suits your site.

The snippet that we’re going to use needs to be added to your functions.php file within a child theme or via a functions plugin. Take a look at our article here on how to add functions to WordPress.

The code to change the WooCommerce Related Products Text:
// How to Change the WooCommerce "Related products" text

add_filter('gettext', 'change_relatedproducts_text', 10, 3);

function change_relatedproducts_text($new_text, $related_text, $source)
{
     if ($related_text === 'Related products' && $source === 'woocommerce') {
         $new_text = esc_html__('Similar Products', $source);
     }
     return $new_text;
}

Using the above snippet we can set the Related Products Text to ‘Similar Products’. 

Additional Snippets / Examples:

Below we’ve featured a few more done for you examples:

Changing the text to ‘More Products’:
// How to Change the WooCommerce "Related products" text

add_filter('gettext', 'change_relatedproducts_text', 10, 3);

function change_relatedproducts_text($new_text, $related_text, $source)
{
     if ($related_text === 'Related products' && $source === 'woocommerce') {
         $new_text = esc_html__('More Products', $source);
     }
     return $new_text;
}
Changing the text to ‘We Think You Might Also Like’:
// How to Change the WooCommerce "Related products" text

add_filter('gettext', 'change_relatedproducts_text', 10, 3);

function change_relatedproducts_text($new_text, $related_text, $source)
{
     if ($related_text === 'Related products' && $source === 'woocommerce') {
         $new_text = esc_html__('We Think You Might Also Like', $source);
     }
     return $new_text;
}

Changing the text to ‘Similar Product Picks’:
// How to Change the WooCommerce "Related products" text

add_filter('gettext', 'change_relatedproducts_text', 10, 3);

function change_relatedproducts_text($new_text, $related_text, $source)
{
     if ($related_text === 'Related products' && $source === 'woocommerce') {
         $new_text = esc_html__('Similar Products', $source);
     }
     return $new_text;
}
Further Reading:

Styling the WooCommerce Product Tabs

How to Change the WooCommerce Add to Cart Button Text

Summary:

We hope this helps and lets you customise the Related Products text to exactly what you need for your site. If you found this useful we would really appreciate a comment or a share thanks!

Tech Typed
Tech Typed
Articles: 186

Leave a Reply

Your email address will not be published. Required fields are marked *