Change "Leave a Comment" Form Title

I searched through your forum and found “solutions” that are not working for me. I am trying to change the “Leave a Comment” text on the forms. Here is what I have at the moment:

add_filter( ‘gettext’, ‘translate_x_strings’, 20, 3 );
function translate_x_strings( $translated_text, $text, $domain ) {
$alt = get_option(‘eri_leave_comment_text’);
switch ( $translated_text ) {
case ‘Leave a Comment’ :
$translated_text = __( $alt, ‘x’ );
break;
}
return $translated_text;
}

add_filter(‘comment_form_defaults’,‘eri_leave_comment_text’, 20 , 2);
function eri_leave_comment_text ($arg) {
$alt = get_option(‘eri_leave_comment_text’);
$arg[‘title_reply’] = __($alt);
return $arg;
}

The meta data changes just fine, and I have tested that the option text does get passed to the “comment_form_defaults” filter by using a JS alert. However, it is not changing the “title_reply”. I have tried adding “20, 2” to the filter, as well as “99”, as well as not adding a 3rd parameter. Nothing works.

Any suggestions?

Hi @tkulow,

Thanks for reaching out.
There might be something that is conflicting with the code, I have checked the following code worked at my local environment. I would suggest you check once by adding it to your child theme’s functions.php

add_filter('comment_form_defaults', 'set_my_comment_title', 20);
function set_my_comment_title( $defaults )
{
    $defaults['title_reply'] = __('Custom leave a comment', 'text-domain');
    return $defaults;
}

If that does not work, I would suggest you hire a developer who can assist you to do the customization or you can avail of our newly launched service called One, where the customization questions are answered.

Thanks

Yeah, still not working. Probably conflict. Thanks for trying, though.

You are most welcome.

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