Rename Related Products title in Woocommerce 3

Viewed 15667

I used to have the following function working to change to Related Products text in Woocommerce.

function my_text_strings( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'Related Products' :
            $translated_text = __( 'Related Books', 'woocommerce' );
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );

It always worked perfectly, but as of Woocommerce version 3.0 or so, this function no longer works.

How should I fix this in order to make it working in the version 3.0 and up?

3 Answers

There is now a filter for that. Name is "woocommerce_product_related_products_heading"

So you can add a little snippet in your own theme functions.php file like :

add_filter('woocommerce_product_related_products_heading',function(){

   return 'My Custom nice related title';

});
Related