WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 9 months ago

Last modified 9 months 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 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Comments Keywords:
Focuses: template Cc:

Description

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
9 months ago

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

#2 @desrosj
9 months 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.

Thanks!

#3 @mic22
9 months 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.