Anyone know how can I change the comment reply text in wordpress to only reflect on specific pages only and not the whole site?
For example the default text site-wide is “Leave a Reply”. But for some specific pages only, I want the text to read “Leave a Review”.
Is there some code I could use in the comments.php file that would make this work?
Code is not tested. But theoretically it should work:
add_filter('comment_form_defaults', 'wpse337366_comment_form_modification');
function wpse337366_comment_form_modification($defaults)
{
// put your condition here
if( is_page('my-page') || is_singular('my_post_type') )
{
$defaults['title_reply'] = __('Leave a Review');
}
return $defaults;
}
You can place the code in a plugin or your theme’s functions.php
.
The code will filter the default texts passed to the comment_form()
.
Reference
comment_form()
– WordPress Developer Resources