我使用的是标准的Wordpress评论表单,但我想在表单中添加单选按钮作为附加字段,如下所示:
我的PHP生成标准表单如下,但我不知道添加、存储和显示(在前端)附加信息的最佳途径:
<?php
$fields = array(
\'author\' =>
\'<p class="comment-form-author"><label for="author">\' . __( \'Name\', \'domainreference\' ) . \'</label> \' .
( $req ? \'<span class="required">*</span>\' : \'\' ) .
\'<input id="author" name="author" placeholder="Enter your name" type="text" value="\' . esc_attr( $commenter[\'comment_author\'] ) . \'" size="30"\' . $aria_req . \' /></p>\',
\'email\' =>
\'<p class="comment-form-email"><label for="email">\' . __( \'Email\', \'domainreference\' ) . \'</label> \' .
( $req ? \'<span class="required">*</span>\' : \'\' ) .
\'<input id="email" name="email" placeholder="Enter your email address" type="text" value="\' . esc_attr( $commenter[\'comment_author_email\'] ) . \'" size="30"\' . $aria_req . \' /></p>\',
\'comment_field\' =>
\'<p class="comment-form-comment"><label for="comment">\' . _x( \'Comment\', \'noun\' ) .
\'</label><textarea id="comment" placeholder="Enter your comment" name="comment" cols="45" rows="8" aria-required="true">\' .
\'</textarea></p>\'
);
$args = array(
\'id_form\' => \'commentform\',
\'class_form\' => \'comment-form\',
\'id_submit\' => \'submit\',
\'class_submit\' => \'submit btn\',
\'name_submit\' => \'submit\',
\'title_reply\' => __( \'Leave a Reply\' ),
\'title_reply_to\' => __( \'Leave a Reply to %s\' ),
\'cancel_reply_link\' => __( \'Cancel Reply\' ),
\'label_submit\' => __( \'Post Comment\' ),
\'format\' => \'xhtml\',
\'fields\' => apply_filters( \'comment_form_default_fields\', $fields )
);
comment_form( $args ); ?>