【发布时间】:2018-05-21 12:15:58
【问题描述】:
我需要在 wordpress 评论表单中插入包装器。我还需要向文本区域、输入字段添加类,并且我需要在标准的 wordpress 评论表单中添加另一个输入字段。现在我正在我的functions.php中尝试以下内容,但没有任何改变,有人可以帮忙吗?
add_filter( 'comment_form_default_fields', 'crb_custom_fields', 2 );
function crb_custom_fields() {
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$custom_fields = array(
'author' =>
'<p class="comment-form-author"><label for="author">' . __( 'Name', 'crb' ) .
( $req ? '<span class="required">*</span>' : '' ) . '</label>' .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
'" size="30"' . $aria_req . ' /></p>',
'email' =>
'<p class="comment-form-email"><label for="email">' . __( 'Email', 'crb' ) .
( $req ? '<span class="required">*</span>' : '' ) . '</label>' .
'<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) .
'" size="30"' . $aria_req . ' /></p>',
'url' =>
'<p class="comment-form-url"><label for="url">' . __( 'Website', 'crb' ) . '</label>' .
'<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .
'" size="30" /></p>',
'comment_field' => '<p class="field comment-form-comment"><label for="comment" class="hidden">' . _x( 'Comment', 'noun' ) .
'</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true">' .
'</textarea></p>',
);
return $custom_fields;
}
【问题讨论】: