我正在搜索相同的解决方案,最后我找到了解决方案,下面的代码对我来说非常适合,我想在评论表单中的提交按钮中添加“btn btn primary”类。
ob_start();
comment_form( $args );
$form = ob_get_clean();
$form = str_replace(\'class="comment-form"\',\'class="comment-form"\', $form);
echo str_replace(\'id="submit"\',\'class="btn btn-primary"\', $form);
我使用的$参数是
$args = array(
\'comment_field\' => \'<p class="comment-form-comment"><label for="comment">Comment</label> <textarea class="form-control" id="comment" name="comment" cols="35" rows="12" aria-required="true"></textarea></p>\',
\'fields\' => array(
\'author\' => \'<p class="comment-form-author"><label for="author">Name <span class="required">*</span></label> <input class="form-control input-comment-author" id="author" name="author" type="text" value="" size="30" aria-required="true"></p>\',
\'email\' => \'<p class="comment-form-email"><label for="email">Email <span class="required">*</span></label> <input class="form-control input-comment-email" id="email" name="email" type="text" value="" size="30" aria-required="true"></p>\',
\'url\' => \'<p class="comment-form-url"><label for="url">Website</label> <input class="form-control input-comment-url" id="url" name="url" type="text" value="" size="30"></p>\',
),
\'cancel_reply_link\' => \'<button class="btn btn-danger btn-xs">Cancel reply</button>\',
\'label_submit\' => \'Post Comment\',);