将此代码放在子主题函数的末尾。php文件。您可以更改每个字段的占位符文本以满足自己的需要。
function wpsites_modify_comment_form_fields($fields){
$fields[\'author\'] = \'<p class="comment-form-author">\' . \'<label for="author">\' . __( \'Author\', \'wpsites.net\' ) . \'</label> \' .
( $req ? \'<span class="required">*</span>\' : \'\' ) .
\'<input id="author" name="author" type="text" placeholder="Real name, please, no keyword spamming!" value="\' .
esc_attr( $commenter[\'comment_author\'] ) . \'" size="30"\' . $aria_req . \' /></p>\';
$fields[\'email\'] = \'<p class="comment-form-email"><label for="email">\' . __( \'Address\', \'wpsites.net\' ) . \'</label> \' .
( $req ? \'<span class="required">*</span>\' : \'\' ) .
\'<input id="email" name="email" type="text" placeholder="You do not have to leave an email address in order to reply" value="\' .
esc_attr( $commenter[\'comment_author_email\'] ) . \'" size="30"\' . $aria_req . \' /></p>\';
$fields[\'url\'] = \'<p class="comment-form-url"><label for="url">\' . __( \'Domain\', \'wpsites.net\' ) . \'</label>\' .
\'<input id="url" name="url" type="text" placeholder="Please Link To Your Own Domain" value="\' .
esc_attr( $commenter[\'comment_author_url\'] ) . \'" size="30" /></p>\';
return $fields;
}
add_filter(\'comment_form_default_fields\',\'wpsites_modify_comment_form_fields\');
来源:
http://wpsites.net/web-design/customize-comment-form-place-holder-input-text-fields-labels/也可以在子主题函数文件中使用此代码之前修改注释注释。
function wpsites_modify_text_before_comment_form($arg) {
$arg[\'comment_notes_before\'] = \'<p class="comment-notes">\' . __( \'You do not have to leave an email address in order to reply.\' ) . \'</p>\';
return $arg;
}
add_filter(\'comment_form_defaults\', \'wpsites_modify_text_before_comment_form\');