Skip to content

Commit

Permalink
Filter found_posts only on wc_query context
Browse files Browse the repository at this point in the history
  • Loading branch information
xristos3490 committed Jul 29, 2020
1 parent d5bedd8 commit 4d4b9e3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions includes/class-wc-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct() {
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();
Expand Down Expand Up @@ -379,7 +379,12 @@ public function remove_product_query_filters( $posts ) {
*
* @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;
Expand Down

0 comments on commit 4d4b9e3

Please sign in to comment.