Created
September 23, 2015 06:40
-
-
Save offroadkev/1c4b70f2619726ad8605 to your computer and use it in GitHub Desktop.
WordPress Comment Form Placeholders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* | |
* Add Placeholders to Comment Forms | |
* Keep in mind that if you want to kill the labels, the easiest way is use display:none in your stylesheet for the labels | |
* | |
*/ | |
add_filter( 'comment_form_default_fields', 'sabretooth_comment_placeholders' ); | |
function sabretooth_comment_placeholders( $fields ) { | |
$fields['author'] = str_replace( | |
'<input', | |
'<input placeholder="Full Name*"', | |
$fields['author'] | |
); | |
$fields['email'] = str_replace( | |
'<input', | |
'<input placeholder="Email*"', | |
$fields['email'] | |
); | |
$fields['url'] = str_replace( | |
'<input', | |
'<input placeholder="Website"', | |
$fields['url'] | |
); | |
return $fields; | |
} | |
/* Add Placehoder in comment Form Field (Comment) */ | |
add_filter( 'comment_form_defaults', 'sabretooth_textarea_placeholder' ); | |
function sabretooth_textarea_placeholder( $fields ) { | |
$fields['comment_field'] = str_replace( | |
'<textarea', | |
'<textarea placeholder="Comment"', | |
$fields['comment_field'] | |
); | |
return $fields; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment