Make WordPress Core

Changeset 36360


Ignore:
Timestamp:
01/20/2016 07:58:23 AM (9 years ago)
Author:
dd32
Message:

Comments: Respect custom pagination params when using wp_list_comments() in a query loop.

[36157] fixed a problem, introduced in 4.4, that caused custom pagination
parameters passed to wp_list_comments(). However, the fix introduced in that
changeset was limited to the is_singular() context, so that the bug remained
when wp_list_comments() is used within a non-singular WP_Query loop. We
fix this by removing the is_singular() check and using the more general
get_the_ID() to identify the correct post_id to use for the secondary
comment query.

Merges [36324] to the 4.4 branch.
Props boonebgorges.
Fixes #35402.

Location:
branches/4.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4

  • branches/4.4/src/wp-includes/comment-template.php

    r36356 r36360  
    19531953         * perform a separate comment query and allow Walker_Comment to paginate.
    19541954         */
    1955         if ( is_singular() && ( $r['page'] || $r['per_page'] ) ) {
     1955        if ( $r['page'] || $r['per_page'] ) {
    19561956            $current_cpage = get_query_var( 'cpage' );
    19571957            if ( ! $current_cpage ) {
     
    19611961            $current_per_page = get_query_var( 'comments_per_page' );
    19621962            if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
     1963
    19631964                $comments = get_comments( array(
    1964                     'post_id' => get_queried_object_id(),
     1965                    'post_id' => get_the_ID(),
    19651966                    'orderby' => 'comment_date_gmt',
    19661967                    'order' => 'ASC',
Note: See TracChangeset for help on using the changeset viewer.