Skip to content

Instantly share code, notes, and snippets.

@offroadkev
Created September 23, 2015 06:40
Show Gist options
  • Save offroadkev/1c4b70f2619726ad8605 to your computer and use it in GitHub Desktop.
Save offroadkev/1c4b70f2619726ad8605 to your computer and use it in GitHub Desktop.
WordPress Comment Form Placeholders
/*
*
* 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