Merge pull request #22621 from woocommerce/fix/22442

Implement main_query parameter in get_meta_query
This commit is contained in:
Mike Jolley 2019-02-01 14:41:26 +00:00 committed by GitHub
commit d09b539f4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -515,7 +515,7 @@ class WC_Query {
global $wpdb, $wp_query;
if ( isset( $wp_query->queried_object, $wp_query->queried_object->term_taxonomy_id, $wp_query->queried_object->taxonomy ) && is_a( $wp_query->queried_object, 'WP_Term' ) ) {
$search_within_terms = get_terms(
$search_within_terms = get_terms(
array(
'taxonomy' => $wp_query->queried_object->taxonomy,
'child_of' => $wp_query->queried_object->term_id,
@ -550,7 +550,7 @@ class WC_Query {
global $wpdb, $wp_query;
if ( isset( $wp_query->queried_object, $wp_query->queried_object->term_taxonomy_id, $wp_query->queried_object->taxonomy ) && is_a( $wp_query->queried_object, 'WP_Term' ) ) {
$search_within_terms = get_terms(
$search_within_terms = get_terms(
array(
'taxonomy' => $wp_query->queried_object->taxonomy,
'child_of' => $wp_query->queried_object->term_id,
@ -601,7 +601,9 @@ class WC_Query {
if ( ! is_array( $meta_query ) ) {
$meta_query = array();
}
$meta_query['price_filter'] = $this->price_filter_meta_query();
if ( $main_query ) {
$meta_query['price_filter'] = $this->price_filter_meta_query();
}
return array_filter( apply_filters( 'woocommerce_product_query_meta_query', $meta_query, $this ) );
}