admin管理员组文章数量:1122846
I'm building a comments template using wp_list_comments();
and comment_form();
— I'm doing it this way because I want to use different containers depending on whether to not there are already comments on the post.
Here's the whole thing:
<?php
// Hide on password protected
if(post_password_required()) {
return;
}
$comment_count = get_comments_number();
if($comment_count > 0):
?>
<div class="ca alt" id="comments">
<div class="width">
<h2 class="comments-title">
<?php
printf( _nx( 'Comments on “%2$s” (1)', 'Comments on “%2$s” (%1$s)', get_comments_number(), 'comments title' ),
number_format_i18n( get_comments_number() ), get_the_title() );
?>
</h2>
<?php
wp_list_comments(array(
'style' => 'div',
'type' => 'comment',
'max_depth' => 3,
'per_page' => 12,
));
?>
</div> <!-- /width -->
</div> <!-- /ca -->
<div class="ca" id="comment-form">
<div class="width">
<?php comment_form(); ?>
</div> <!-- /width -->
</div> <!-- /ca -->
<?php else: ?>
<div class="ca alt" id="comment-form">
<div class="width">
<?php comment_form(); ?>
</div> <!-- /width -->
</div> <!-- /ca -->
<?php endif; ?>
My problem is that although the "reply" link appears under each comment it doesn't work as expected. It simply creates an anchor link to the comment it is under, and scrolls it to the top of the viewport. Example:
<a rel="nofollow" class="comment-reply-link" href="#comment-3" data-commentid="3" data-postid="2679" data-belowelement="comment-3" data-respondelement="respond" data-replyto="Reply to [name]" aria-label="Reply to [name]">Reply</a>
The hover label in the browser for this shows: Go to #comment-3 on this page
.
Why is this happening? How can I make it behave as expected?
本文标签: Why does the reply link in comments template scroll to comment position
版权声明:本文标题:Why does the reply link in comments template scroll to comment position? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736302596a1931591.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论