Media: Improve count in Media Library pagination.

Deleting all visible items on the last page of the media library previously left a blank page with no media items available. Using `wp_count_attachements` instead of `found_posts` solves the problem.

Props donsony, karmatosed, desrosj, mista-flo, justinahinon.

Fixes #39968.


git-svn-id: https://develop.svn.wordpress.org/trunk@49567 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Anthony Burchell 2020-11-12 15:38:32 +00:00
parent 4006c07417
commit 4afa79feed

View File

@ -100,8 +100,7 @@ class WP_Media_List_Table extends WP_List_Table {
$this->set_pagination_args(
array(
'total_items' => $wp_query->found_posts,
'total_pages' => $wp_query->max_num_pages,
'total_items' => array_sum( (array) wp_count_attachments() ),
'per_page' => $wp_query->query_vars['posts_per_page'],
)
);