Ignore hierarchy in pagination calculation when comment threading is disabled.

In order to calculate comment pagination when newest comments are displayed
first, `comments_template()` must perform a separate query to determine the
total number of paginating comments available on a post. See [34729], #8071,
pagination calculation - can be defined as a top-level comment, or a comment
with `parent=0`. However, when comment threading is disabled, yet comments
exist in the database that have parents, all comments - even those with a
parent - are "paginating". (This typically happens when comments threading was
once enabled, but has since been turned off.) As such, the total-paginating-
comments query should only be limited to top-level comments when
'thread_comments' is disabled.

Props jmdodd.
Fixes #35419.

git-svn-id: https://develop.svn.wordpress.org/trunk@36275 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2016-01-13 03:12:34 +00:00
parent b9e083e360
commit f7d238dfe3
2 changed files with 47 additions and 1 deletions

View File

@@ -1323,10 +1323,13 @@ function comments_template( $file = '/comments.php', $separate_comments = false
'count' => true,
'orderby' => false,
'post_id' => $post->ID,
'parent' => 0,
'status' => 'approve',
);
if ( $comment_args['hierarchical'] ) {
$top_level_args['parent'] = 0;
}
if ( isset( $comment_args['include_unapproved'] ) ) {
$top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
}