[wp-trac] [WordPress Trac] #65392: "Show more comments" button in comments metabox doesn't load new comments if they are of a type different than 'comment'

WordPress Trac noreply at wordpress.org
Tue Jun 2 13:35:56 UTC 2026


#65392: "Show more comments" button in comments metabox doesn't load new comments
if they are of a type different than 'comment'
----------------------------+-----------------------------
 Reporter:  aljullu         |      Owner:  (none)
     Type:  defect (bug)    |     Status:  assigned
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Comments        |    Version:  trunk
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 When comments have a custom type (ie, `review`) the 'Load more comments'
 button in the comments metabox in the editor doesn't work properly: it
 duplicates the existing comments listed instead of loading the remaining
 ones.

 **Steps to reproduce (custom code)**

 1. Add this code snippet somewhere in your page. tl;dr, it creates a
 custom post type and makes its comments have the `cpt_response` type:

 {{{#!php
 <?php
 add_action( 'init', function () {
         register_post_type(
                 'my_cpt',
                 array(
                         'labels'       => array(
                                 'name'          => 'My custom CPT
 entries',
                                 'singular_name' => 'My custom CPT entry',
                                 'add_new'       => 'Add entry',
                                 'add_new_item'  => 'Add new entry',
                         ),
                         'public'       => true,
                         'show_ui'      => true,
                         'show_in_menu' => true,
                         'show_in_rest' => true,
                         'supports'     => array( 'title', 'comments' ),
                         'menu_icon'    => 'dashicons-testimonial',
                         'has_archive'  => false,
                 )
         );
 }, 0 );

 add_filter( 'preprocess_comment', function ( $data ) {
         $post_id = isset( $data['comment_post_ID'] ) ? (int)
 $data['comment_post_ID'] : 0;
         if ( $post_id && 'my_cpt' === get_post_type( $post_id ) ) {
                 $data['comment_type'] = 'cpt_response';
         }
         return $data;
 }, 1 );
 }}}
 2. In wp-admin, go to ''My custom CPT entries'' > ''Add new entry''.
 3. Add a title and publish.
 4. In the frontend, add at least 21 comments to that entry.
 5. Back in the editor, verify the comments metabox shows comments 21-12
 (they are ssorted by recency).
 6. Click on ''Show more comments''.
 7. Notice comments 21-12 are loaded again, appearing repeated.

 Expected behavior: comments 11-2 should be loaded, instead.

 **Steps to reproduce (WooCommerce)**

 The same can be reproduced in WooCommerce.

 1. Create a product.
 2. In the frontend, add 21 reviews.
 3. In the product editor, verify the reviews metabox shows reviews 21-12.
 4. Click on ''Show more comments''.
 5. Notice comments 21-12 are loaded again, appearing repeated.

 **Explanation**

 The current logic to load new comments in the comment's metabox in the
 editor assumes the HTML elements will have the `comment` class, but that's
 only the case for comments of type `comment`. If comments have a different
 type, like `review`, they won't be counted and the button will fail to
 work.

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


More information about the wp-trac mailing list