我的页面评论分为5组。让我假设我的页面上有20条评论。当我添加新评论时,网址会更改为comment-page-5/#comment-21
。
但它应该分别是页面或页面1,因为我的订单设置如下:
5
个最高评论和默认显示first
页面的网页所以我的评论从新到旧。在没有comment-page-x
我像这样分页
<?php
# The comment functions use the query var 'cpage', so we'll ensure that's set
$page = intval( get_query_var( 'cpage' ) );
if ( 0 == $page ) {
$page = 1;
set_query_var( 'cpage', $page );
}
$comments_per_page = get_option( 'comments_per_page' ) ?? 5 ;
$comments = get_comments( array( '' ) );
?>
<ol class="single-comment-list list-unstyled pl-0">
<?php
wp_list_comments( array(
'style' => 'ol',
'max_depth' => 3,
'short_ping' => false,
'per_page' => $comments_per_page,
'page' => $page,
'reverse_top_level' => false,
'walker' => new Bootstrap_Comment_Walker(),
), $comments );
?>
</ol>
<?php if ( get_comment_pages_count( $comments, $comments_per_page ) > 1 ) : // are there comments to navigate through ?>
<nav id="comment-nav" class="">
<ul class="d-flex list-unstyled">
<li class="flex-fill nav-previous"><?php previous_comments_link( '<span class="fas fa-arrow-left pr-2"></span>Neuere Kommentare' ); ?></li>
<li class="flex-fill nav-next text-right"><?php next_comments_link( '<span class="fas fa-arrow-right pr-2"></span>Ältere Kommentare' ); ?></li>
</ul>
</nav>
<?php endif; ?>
我的问题是,是什么导致它这样做?这是wordpress的预期行为吗?