Make WordPress Core

Opened 7 years ago

Closed 3 years ago

#41688 closed defect (bug) (worksforme)

Wrong term pagination when altering the term query in custom taxonomy terms list

Reported by: opportus's profile opportus Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Administration Keywords:
Focuses: ui, administration, template Cc:

Description

WP outputs the wrong term pagination if we alter the term query in custom taxonomy terms list with for example the list_terms_exclusions filter hook.
In the screenshot below, we should have only 3 items in the pagination, but as you can see we get 21 items instead.

https://i.imgur.com/pFUCG8P.png

I believe the problem comes from this line:

https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-wp-terms-list-table.php#L125

'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ),

Shouldn't the pagination be defined based on the term query's result instead?

For more details about this issue, see:

https://wordpress.stackexchange.com/questions/277088/filter-taxonomy-admin-pagination/277590#277590

Change History (2)

This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.


3 years ago

#2 @peterwilsoncc
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Hi @opportus and welcome to trac!

I'd like to apologies for the amount of time it's taken for you to receive a reply to this ticket. It was discussed a short time ago during a triage session.

While your screen shots show the report was valid at the time you logged it, it appears the issue has been fixed in the meantime.

Using some test code to exclude terms via filters (either using the get_terms_args or list_terms_exclusions filter) updated the pagination and total count on the taxonomy page to match the number of items displayed.

Note: See TracTickets for help on using tickets.