Forums › Forums › Search & Filter Pro › Product Search additional filter by code
- This topic has 2 replies, 2 voices, and was last updated 7 years, 2 months ago by Anonymous.
-
Anonymous(Private) September 7, 2017 at 10:00 am #129699
Hi,
I’m adding an additional parameter in the url, to append some meta_query to the filtered page. The problem is that my code is not affecting in the result and I am expecting that the search plugin is not allowing me to append to meta query!
I am adding the following:
function some_product_query( $q ) {
if ( isset($_GET[‘check_vendor’]) ) {
$meta_query = $q->get( ‘meta_query’ );$meta_query[‘relation’] = ‘AND’;
$meta_query[] = array(
array(
‘key’ => ‘product_vendor’,
‘value’ => ‘some_vendor’,
‘compare’ => ‘LIKE’
)
);$q->set( ‘meta_query’, $meta_query );
}
}the previous code is hooked to the action: woocommerce_product_query
but it is not affecting the resulted screen. Could you please help whether this is caused because of your plugin? if yes, is it possible to solve it somehow?
Trevor(Private) September 7, 2017 at 5:31 pm #129800The only code that I have seen like that is when using the Custom Display Results method, pre_get_posts method, as seen here:
https://www.designsandcode.com/documentation/search-filter-pro/search-results/custom/#pre_get_posts
Otherwise, you stand the risk that our filter will override your arguments. OR, you might be able to use this:
-
AuthorPosts