diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index b677851cd7..4ef67dd74d 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -1925,6 +1925,27 @@ function wp_list_comments( $args = array(), $comments = null ) { */ $r = apply_filters( 'wp_list_comments_args', $r ); + /* + * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query, + * perform a separate comment query and allow Walker_Comment to paginate. + */ + if ( is_singular() && ( $r['page'] || $r['per_page'] ) ) { + $current_cpage = get_query_var( 'cpage' ); + if ( ! $current_cpage ) { + $current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages; + } + + $current_per_page = get_query_var( 'comments_per_page' ); + if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) { + $comments = get_comments( array( + 'post_id' => get_queried_object_id(), + 'orderby' => 'comment_date_gmt', + 'order' => 'ASC', + 'status' => 'all', + ) ); + } + } + // Figure out what comments we'll be looping through ($_comments) if ( null !== $comments ) { $comments = (array) $comments; diff --git a/wp-includes/version.php b/wp-includes/version.php index b488b7f055..efca187e44 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4.1-alpha-36155'; +$wp_version = '4.4.1-alpha-36158'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.