/** * Set filter. * * @param wp_query $q */ public function setFilter($q) { // check for if we are on main query and product archive page if (!is_main_query() && !is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) { return; } $search_results = $this->productIdsForGivenKeyword(); $taxono_results = $this->filteredProductIdsForTerms(); if (sizeof($search_results) > 0 && sizeof($taxono_results) > 0) { $post__in = array_intersect($search_results, $taxono_results); } elseif (sizeof($search_results) > 0 && sizeof($taxono_results) === 0) { $post__in = $search_results; } else { $post__in = $taxono_results; } $q->set('meta_query', $this->queryForMeta()); $q->set('post__in', $post__in); return; }