Change Submit Button Text in WordPress Comment Form

How to Change Submit Button Text in WordPress Comment Form

in Comments
Google+ LinkedIn

Comment system is an integral part of WordPress and that’s why we are always looking for ways to customize WordPress comments. In earlier articles, we have already seen how to use circular shaped avatars, change reply link text in threaded comments, highlight post author comments and how to automatically link twitter username in comments. In this article I will show you how you can change submit button text in comment form instead of default “Post Comment”. For branding purposes or may be to spice up comment form, you might want to change the submit button text into something more interesting and unique.

WordPress comment form is generated by a single WordPress function, that’s why it’s not as easy as it appears to change submit button text. So you are left with two options, either you can build comment form from scratch or you can use WordPress filters to alter function. To be honest, second option is a lot easier than first one and much better too.

Just paste this code snippet below, in your theme’s functions.php file and it will change submit button text to “Hit me!” instead of default test “Post Comment”. Of course you can change this text to something more relevant to your website.

// change submit button text in wordpress comment form
function wcs_change_submit_button_text( $defaults ) {
    $defaults['label_submit'] = 'Hit me!';
    return $defaults;
}
add_filter( 'comment_form_defaults', 'wcs_change_submit_button_text' );

source

Share the love

If you like this snippet, share it with others!

Leave a Reply

Your email address will not be published. Required fields are marked *