Merge pull request #27166 from xristos3490/fix/27163

[4.4] Pagination of custom product queries broken
This commit is contained in:
Néstor Soriano 2020-07-31 08:29:24 +02:00 committed by GitHub
commit add9fd791b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -45,7 +45,7 @@ class WC_Query {
add_action( 'parse_request', array( $this, 'parse_request' ), 0 );
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
add_filter( 'the_posts', array( $this, 'remove_product_query_filters' ) );
add_filter( 'found_posts', array( $this, 'adjust_posts_count' ) );
add_filter( 'found_posts', array( $this, 'adjust_posts_count' ), 10, 2 );
add_filter( 'get_pagenum_link', array( $this, 'remove_add_to_cart_pagination' ), 10, 1 );
}
$this->init_query_vars();
@ -377,10 +377,16 @@ class WC_Query {
*
* @since 4.4.0
* @param int $count Original posts count, as supplied by the found_posts filter.
* @param WP_Query $query The current WP_Query object.
*
* @return int Adjusted posts count.
*/
public function adjust_posts_count( $count ) {
public function adjust_posts_count( $count, $query ) {
if ( ! $query->get( 'wc_query' ) ) {
return $count;
}
$posts = $this->get_current_posts();
if ( is_null( $posts ) ) {
return $count;