From ef6f1354e9e83f584d22782a77ab46ed6bec099c Mon Sep 17 00:00:00 2001
From: Florian TIAR <contact@tiar-florian.fr>
Date: Tue, 27 Sep 2016 10:41:41 +0200
Subject: [PATCH] Comments : Fix incorect page number for comments due to parent arg

---
 wp-includes/comment.php | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index 27524c5..a0d6e3c 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -902,11 +902,14 @@ function get_page_of_comment( $comment_ID, $args = array() ) {
 	}
 
 	if ( null === $page ) {
+		$parent = 0;
 		if ( '' === $args['max_depth'] ) {
-			if ( get_option('thread_comments') )
+			if ( get_option('thread_comments') ) {
 				$args['max_depth'] = get_option('thread_comments_depth');
-			else
+			} else {
 				$args['max_depth'] = -1;
+				$parent = '';
+			}
 		}
 
 		// Find this comment's top level parent if threading is enabled
@@ -919,7 +922,7 @@ function get_page_of_comment( $comment_ID, $args = array() ) {
 			'fields'     => 'ids',
 			'count'      => true,
 			'status'     => 'approve',
-			'parent'     => 0,
+			'parent'     => $parent,
 			'date_query' => array(
 				array(
 					'column' => "$wpdb->comments.comment_date_gmt",
-- 
2.6.3.windows.1

