Comments: 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.

Merges [36275] to the 4.4 branch.
Props jmdodd.
Fixes #35419.

Built from https://develop.svn.wordpress.org/branches/4.4@36362


git-svn-id: http://core.svn.wordpress.org/branches/4.4@36329 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2016-01-20 08:32:27 +00:00
parent 7baf5daba3
commit 7d81c464aa
1 changed files with 4 additions and 1 deletions

View File

@ -1322,10 +1322,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'];
}