Make WordPress Core

Changeset 36324


Ignore:
Timestamp:
01/15/2016 07:47:17 PM (9 years ago)
Author:
boonebgorges
Message:

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.

Fixes #35402.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r36322 r36324  
    19271927         * perform a separate comment query and allow Walker_Comment to paginate.
    19281928         */
    1929         if ( is_singular() && ( $r['page'] || $r['per_page'] ) ) {
     1929        if ( $r['page'] || $r['per_page'] ) {
    19301930            $current_cpage = get_query_var( 'cpage' );
    19311931            if ( ! $current_cpage ) {
     
    19351935            $current_per_page = get_query_var( 'comments_per_page' );
    19361936            if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
     1937
    19371938                $comments = get_comments( array(
    1938                     'post_id' => get_queried_object_id(),
     1939                    'post_id' => get_the_ID(),
    19391940                    'orderby' => 'comment_date_gmt',
    19401941                    'order' => 'ASC',
Note: See TracChangeset for help on using the changeset viewer.