Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#51537 closed defect (bug) (invalid)

Changes made to comments_array hook do not take effect if 'per_page' parameter is set in wp_list_comments()

Reported by: mic22's profile mic22 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Comments Keywords:
Focuses: template Cc:


If in the comments.php template file we use wp_list_comments() with a parameter 'per_page', any changes made to comments_array Hook are omitted or reset.

Steps to reproduce:

  1. Set the 'per_page' argument like this: wp_list_comments( [ 'per_page' => '20' ] );
  2. Add this line to functions.php: add_filter( 'comments_array', 'array_reverse' );

The line in functions.php will not take effect. But if you remove the 'per_page' parameter, everything works and the comment order is reversed.

Change History (3)

#1 @mic22
4 years ago

  • Resolution set to invalid
  • Status changed from new to closed

#2 @desrosj
4 years ago

  • Keywords needs-testing removed
  • Milestone Awaiting Review deleted
  • Version 5.5.1 deleted

Hi @mic22,

Welcome to Trac!

I just wanted to confirm that closing this ticket was intentional. If you were able to fix the problem, do you mind sharing what was causing the issue? It may help others in the future.


#3 @mic22
4 years ago

Upon inspecting more code and reading comments in php I came to realize that it's an intended behavior of wordpress. I closed the ticket, because this does not qualify as a bug. Yet I think it could be revisited in the future and the code should be improved to allow better comment handling.

Note: See TracTickets for help on using tickets.