• Resolved robmcp

    (@robmcp)


    Can anyone help with this? (I know it can be done)

    See this Woocommerce demo link
    Demo product with Related Products

    At the bottom of the page are some related products. I want the H2 tag “Related Products” to say something else. Does anyone know where in the system I can find that?

    <section class="related products">
    
    		<h2>Related products</h2>
    
    		<ul class="products">
    

    The code above is copied from F12 inspect. Site uses Divi and Woocommerce

    I know this can be done as I have done it before on another site, however having lost the record of how this was altered, I am somewhat (embarassed) Stuck!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there!!

    You should be able to use the following snippet to change that “Related Products” header text:

    
    add_filter('woocommerce_product_related_products_heading', 'my_custom_related_products_heading');
    function my_custom_related_products_heading() {
        return 'My New Header Text!!';
    }
    

    Alternatively, you can do this by using a free translation plugin like Loco Translate (?https://www.ads-software.com/plugins/loco-translate/?). This will allow you to find that phrase and change it to be what you’d like. There’s a great guide for this available here:
    https://danielsantoro.com/using-loco-translate-change-wordpress-strings/

    I hope that helps!

    Thread Starter robmcp

    (@robmcp)

    Thanks Kelly, Will try that. Can you confirm that will go in the functions.php file?
    Will also look at the translate plug in. (This is infuriating as I have done this on another site but can find neither hide nor hair of any functions.php override.

    Thread Starter robmcp

    (@robmcp)

    Hi Kelly, tried that to change this

    < section class “up-sells upsells products” > < h2 > Related Products < / h2 >

    Is the filter name woocommerce_product_related_products_heading correct for upsells ?

    It would seem not.

    Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there!

    Can you confirm that will go in the functions.php file?

    Yep! That code snippet would go in your child theme’s functions.php file, or could be added via a plugin that allows custom functions to be added, such as the Code Snippets ( https://www.ads-software.com/plugins/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.

    Is the filter name woocommerce_product_related_products_heading correct for upsells ?

    No, I think that filter will only work for the Related Products heading.

    Checking the /woocommerce/templates/single-product/up-sells.php file, it doesn’t look like there is any filter available for changing the Upsells heading — “You may also like:”

    To change that, you can either use the Loco Translate method to change the string, or you can override the template itself by copying it into your child theme and editing the text. We have a guide for overriding template files here:
    https://docs.woocommerce.com/document/template-structure/

    I hope that helps!

    Thread Starter robmcp

    (@robmcp)

    Thsi really is annoying, I can’t remember how I did this previously. Documentation!!!!!!

    There has to be a way to do it. I have even searched through phpmyadmin but just can’t find it. Thanks, will keep looking on this.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Amend the H2 Related Products header text’ is closed to new replies.