Archived topic
Changing Comment title and button
10 replies · Started by Luis on October 28, 2020
Hi,
I tried searching for a while and came up empty...
Where it says "Leave a Comment" and the button "Post Comment" for this demo > (https://gpsites.co/read/read-post/)
How do I go about changing this? Is there somewhere simple to edit this or is this with some CSS?
Thank you
Hi there,
this document explains how to change the comment title:
https://docs.generatepress.com/article/generate_leave_comment/
And this filter is used for the Comment Button text:
https://docs.generatepress.com/article/generate_post_comment/
Heres an example of both filters:
add_filter( 'generate_leave_comment', function () {
return 'Comment title text';
} );
add_filter( 'generate_post_comment',function () {
return 'Post comment button text';
} );
Thank you David.
That's fixed it. :)
Glad to hear that
David,
Thank you!
You're welcome
Could this be implemented on one specific page instead of the whole site?
Hi lakshman,
Yes, you can add conditions to the code, for example, if you want to make changes for the post with id 1
add_filter( 'generate_leave_comment', function () {
if (is_single('1')) {
return 'Comment title text';
}
return 'Leave a Comment';
} );
add_filter( 'generate_post_comment',function () {
if (is_single('1')) {
return 'Post comment button text';
}
return 'Post comment';
} );
Hi Ying,
Thank you so much for the prompt response! Above solution worked well for posts but not for pages. Is there anything I need to do to implement it on a specific page only?
update: I found a solution! I just asked chatGPT to rewrite for a page and it worked! :D
// Change comment form title and submit button for specific page with ID 123
add_filter( 'generate_leave_comment', function () {
if ( is_page( 123 ) ) {
return 'Comment title text';
}
return 'Leave a Comment';
} );
add_filter( 'generate_post_comment', function () {
if ( is_page( 123 ) ) {
return 'Post comment button text';
}
return 'Post Comment';
} );
Thanks for your help!
I just asked chatGPT to rewrite for a page and it worked!
Haha, that's a smart move :) Glad to hear that!