Merge pull request #27166 from xristos3490/fix/27163
[4.4] Pagination of custom product queries broken
This commit is contained in:
commit
add9fd791b
|
@ -45,7 +45,7 @@ class WC_Query {
|
||||||
add_action( 'parse_request', array( $this, 'parse_request' ), 0 );
|
add_action( 'parse_request', array( $this, 'parse_request' ), 0 );
|
||||||
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
|
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
|
||||||
add_filter( 'the_posts', array( $this, 'remove_product_query_filters' ) );
|
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 );
|
add_filter( 'get_pagenum_link', array( $this, 'remove_add_to_cart_pagination' ), 10, 1 );
|
||||||
}
|
}
|
||||||
$this->init_query_vars();
|
$this->init_query_vars();
|
||||||
|
@ -377,10 +377,16 @@ class WC_Query {
|
||||||
*
|
*
|
||||||
* @since 4.4.0
|
* @since 4.4.0
|
||||||
* @param int $count Original posts count, as supplied by the found_posts filter.
|
* @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.
|
* @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();
|
$posts = $this->get_current_posts();
|
||||||
if ( is_null( $posts ) ) {
|
if ( is_null( $posts ) ) {
|
||||||
return $count;
|
return $count;
|
||||||
|
|
Loading…
Reference in New Issue