Changing 'Leave a Reply' text in Icon

Hey guys, I’m using Pro Child Theme and trying to change the comments section title (from ‘Comments’ to ‘Discussion’ and also the ‘Leave a Reply’ text to ‘Reply’.

I looked in the /views/icon/wp-comments.php but I can’t really see that bit of copy.

Any help would be awesome.

Hey Juan,

You will need to use WordPress’ gettext filter for this. Here’s a sample code to be added in your child theme’s functions.php. Please note that this code serves only as a guide and issues that might arise from the use of it and further enhancement would be outside the scope of our support. It is to our understanding that you will learn how to use the said filter or even learn WordPress development in order to maintain and/or enhance the code.

// Translate Strings
add_filter( 'gettext', 'translate_x_strings', 20, 3 );

function translate_x_strings( $translated_text, $text, $domain ) {

    if ( is_singular() ) {

        switch ( $translated_text ) {

            case 'Comments' :

                $translated_text = __( 'Discussion', '__x__' );
                break;

            case 'Leave a Reply' :

                $translated_text = __( 'Reply', '__x__' );
                break;
        }

    }

    return $translated_text;
}

Thanks.

1 Like

Interesting, afraid this solution it will also replace any other instance of the word ‘Comments’ on the page, but can take it from there.

Thanks!

On behalf of my colleague, you’re welcome. Cheers! :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.