我的主题有一个标准的评论表单。当用户填写表单并提交表单时,注释将显示在注释列表中。但页面不会滚动到新发布的评论。每个注释url都有一个定位点:
http://example.com/post-name/#comment-3
如何使页面在提交后立即滚动到新发布的评论?
EDIT:
我的意见表:
$args = array(
\'fields\' => apply_filters(
\'comment_form_default_fields\', array(
\'author\' =>\'Ismingiz\'.\'<span style="color:red;">*</span><br>\'.\'<input id="author" class="form-control" name="author" type="text" value="\' . esc_attr( $commenter[\'comment_author\'] ) . \'" size="30"/><br>\',
\'email\' => \'Email\'.\'<span style="color:red;">*</span><br>\'.\'<input id="email" class="form-control" name="email" type="text" value="\' . esc_attr( $commenter[\'comment_author_email\'] ) .\'" size="30" /><br>\' ,)
),
\'comment_field\' => \'\' . \'<div class="input-group commenting-input-group input-group-lg"><textarea id="comment" class="form-control" name="comment" placeholder="Fikringiz matni..." cols="45" rows="8" aria-required="true"></textarea><br>\',
\'comment_notes_before\' => \'\',
\'title_reply\' => \'\',
\'class_submit\' => \'btn send-comment-button\',
\'label_submit\' => __( \'Yuborish\' ),
\'comment_notes_after\' => \'\',
\'submit_field\' => \'<p class="form-submit">%1$s %2$s</a></div>\',
\'logged_in_as\' => \'\',
);
comment_form($args);
?>
注释循环:
function format_comment() { ?>
<div class="col-xs-2 col-md-3">
<?php echo get_avatar( get_the_author_meta( \'ID\' ), 32 ); ?>
</div>
<div class="col-xs-10 col-md-9 comment-content">
<div class="commenter">
<a href="<?php comment_link(); ?>"><?php comment_author(); ?></a>
<div class="comment-date">
<?php comment_date(); ?>
</div>
</div>
<div class="comment">
<?php comment_text(); ?>
</div>
</div>