[wp-trac] [WordPress Trac] #35402: per_page parameter no longer works in wp_list_comments

WordPress Trac noreply at wordpress.org
Mon Jan 11 13:54:07 UTC 2016


#35402: per_page parameter no longer works in wp_list_comments
--------------------------+-----------------------------
 Reporter:  Ninos Ego     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  4.4.1
 Severity:  normal        |   Keywords:
  Focuses:  template      |
--------------------------+-----------------------------
 The per_page & page parameters are not working anymore in the
 wp_list_comments()-function since 4.4. For the singular page you fixed
 that bug (see #35175), in the loop the bug still exists.

 This bug affects if $wp_query->max_num_comment_pages is >= 1 (page &
 per_page parameters will be changed to 0).

 https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-includes
 /comment-template.php#L1976

 I think it's because the WP_Comment_Query uses the param
 'comments_per_page' from admin panel (options) instead of the per_page
 parameter. Because of that $wp_query->max_num_comment_pages returns a
 wrong value. Changing 'comments_per_page' to 2 solves my problem.

 Following function is not working as expected (I get all comments):
 <?php wp_list_comments( array(
         'page'     => $cpaged,
         'per_page' => 2
 ) ); ?>

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35402>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list