[Resolved] Changing Comment title and button

Home Forums Support [Resolved] Changing Comment title and button

Home Forums Support Changing Comment title and button

  • This topic has 10 replies, 5 voices, and was last updated 1 year ago by Ying.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1507431
    Luis

    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

    #1507554
    David
    Staff
    Customer Support

    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';
    } );

    https://docs.generatepress.com/article/adding-php/

    #1508750
    Luis

    Thank you David.

    That’s fixed it. πŸ™‚

    #1508934
    David
    Staff
    Customer Support

    Glad to hear that

    #1687127
    Bob

    David,

    Thank you!

    #1687135
    David
    Staff
    Customer Support

    You’re welcome

    #2547974
    lakshman

    Could this be implemented on one specific page instead of the whole site?

    #2547990
    Ying
    Staff
    Customer Support

    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';
    } );
    #2548019
    lakshman

    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?

    #2548203
    lakshman

    update: I found a solution! I just asked chatGPT to rewrite for a page and it worked! πŸ˜€

    // 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!

    #2549038
    Ying
    Staff
    Customer Support

    I just asked chatGPT to rewrite for a page and it worked!

    Haha, that’s a smart move πŸ™‚ Glad to hear that!

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.