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. git-svn-id: https://develop.svn.wordpress.org/trunk@36324 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4d17d22a47
commit
50068ee5b9
|
@ -1926,7 +1926,7 @@ function wp_list_comments( $args = array(), $comments = null ) {
|
||||||
* If 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
|
* 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.
|
* perform a separate comment query and allow Walker_Comment to paginate.
|
||||||
*/
|
*/
|
||||||
if ( is_singular() && ( $r['page'] || $r['per_page'] ) ) {
|
if ( $r['page'] || $r['per_page'] ) {
|
||||||
$current_cpage = get_query_var( 'cpage' );
|
$current_cpage = get_query_var( 'cpage' );
|
||||||
if ( ! $current_cpage ) {
|
if ( ! $current_cpage ) {
|
||||||
$current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
|
$current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
|
||||||
|
@ -1934,8 +1934,9 @@ function wp_list_comments( $args = array(), $comments = null ) {
|
||||||
|
|
||||||
$current_per_page = get_query_var( 'comments_per_page' );
|
$current_per_page = get_query_var( 'comments_per_page' );
|
||||||
if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
|
if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
|
||||||
|
|
||||||
$comments = get_comments( array(
|
$comments = get_comments( array(
|
||||||
'post_id' => get_queried_object_id(),
|
'post_id' => get_the_ID(),
|
||||||
'orderby' => 'comment_date_gmt',
|
'orderby' => 'comment_date_gmt',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
'status' => 'all',
|
'status' => 'all',
|
||||||
|
|
Loading…
Reference in New Issue