I have a standard comment form in my theme. When user fills in the form and submits it, the comment appears in the comments list. But page does not scroll to the newly posted comment. Each comment url has an anchor:
How to make the page scroll to the newly posted comment right after post submit?
EDIT:
My comment form:
$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);
?>
Comments loop:
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>
I have a standard comment form in my theme. When user fills in the form and submits it, the comment appears in the comments list. But page does not scroll to the newly posted comment. Each comment url has an anchor:
http://example/post-name/#comment-3
How to make the page scroll to the newly posted comment right after post submit?
EDIT:
My comment form:
$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);
?>
Comments loop:
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>
Share Improve this question edited Nov 7, 2016 at 9:44 Azamat asked Nov 7, 2016 at 6:45 AzamatAzamat 3611 gold badge4 silver badges15 bronze badges 4 |
1 Answer
Reset to default 0It seems that the WordPress comment box isn't working properly. Or maybe you are using any comment plugin like CommentLuv then it's the Javascript problem. You can check the comment box code in the theme. The loop showing the answers should be perfect to fetch the URL of the author.
<a href="<?php comment_link(); ?>">
this is the anchor link! – Azamat Commented Nov 7, 2016 at 17:55