[wp-trac] [WordPress Trac] #35805: Reverse page order in wp_list_comments() with newest comments first

WordPress Trac noreply at wordpress.org
Fri Feb 12 00:21:28 UTC 2016


#35805: Reverse page order in wp_list_comments() with newest comments first
--------------------------+-----------------------------
 Reporter:  Ninos Ego     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:  template      |
--------------------------+-----------------------------
 Hey there,
 since wp 4.4 there were lots of bugs in the wp_list_comments()-function.
 Some of them are already fixed, now I found another one.
 If you change the comments order from default (oldest first) to newest
 first, the page order is wrong (reverse page order).


 == Example ==
 You have 4 pages by sending following param you get these pages:
 {{{
 page=1 -> 4
 page=2 -> 3
 page=3 -> 2
 page=4 -> 1
 }}}


 == How I call this function ==

 Inside the post-loop I'm calling:
 {{{#!php
 <?php
 while ( have_posts() ) : the_post();
     get_template_part( 'templates/content', 'comment' );
 }}}

 The template file templates/content-comment.php has following content:
 {{{#!php
 <?php if ( ! defined( 'ABSPATH' ) ) {
         exit;
 } ?>

 <?php global $withcomments; ?>
 <?php $withcomments = 1; ?>
 <?php add_filter( 'comments_template', '__return_true' ); ?>

 <?php if ( comments_open() || get_comments_number() ) : ?>
         <div class="entry-comment">
                 <?php comments_template( '/comments-content.php' ); ?>
         </div>
 <?php endif; ?>
 }}}

 And comments-content.php has following part:
 {{{#!php
 <?php
 wp_list_comments( array(
         'page'     => $cpaged, // Variable defined before, default: 1
         'per_page' => 2
 ) );
 ?>
 }}}

 PS: In ticketing system the version 4.4.2 is not available :-)

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


More information about the wp-trac mailing list