我想comment_form()
在 WordPress 中自定义函数的输出。要编辑字段和文本区域,我使用了以下代码并且一切正常。
<?php
$req = get_option( 'require_name_email' );
$fields = array(
// redefine author field
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name:' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label>' .
'<div class="input-prepend"><span class="add-on"><i class="icon-user"></i></span><input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . 'aria-required="true"' . ' required /></p>',
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email Address:' ) . ( $req ? ' <span class="required">*</span><br/>' : '' ) . '</label>' .
'<div class="input-prepend"><span class="add-on"><i class="icon-envelope"></i></span><input required id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . 'aria-required="true"' . ' required /></div></p>',
'url' => '<p class="comment-form-url"><label for="url">' . __( 'Your Website:' ) . '</label>' .
'<div class="input-prepend"><span class="add-on"><i class="icon-globe"></i></span><input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></div></p>'
);
$comments_args = array(
'fields' => $fields,
// redefine your own textarea (the comment body)
'comment_field' => '<p class="comment-form-comment"><label for="comment">' . 'Comment' . '</label><textarea id="comment" name="comment" class="span12" rows="5" aria-required="true"></textarea></p>',
);
comment_form( $comments_args );
?>
这是结果:
现在,我想class="btn btn-primary"
为提交按钮添加两个 CSS 类();如果不使用 jQuery,我怎么能做到这一点?
笔记:
有关解决方案,请阅读有关标有绿色符号的答案的评论。