-
Search Results
-
When using the sf_edit_query_args filter with WooCommerce the following problem is occurring:
At page load the filter is working fine. When scrolling to the ‘next page’ with infinite scroll, all the filter options are ‘forgotten’.
This is the code we are using:
function filter_products( $query_args, $sfid ) { $query_args['tax_query'] = [ 'relation' => 'AND', [ 'taxonomy' => 'pa_merk', 'field' => 'slug', 'terms' => array( 'antwrp' ), ],[ 'taxonomy' => 'pa_kleur', 'field' => 'slug', 'terms' => array( '202-medium-grey-chine' ), ] ]; return $query_args; } add_filter( 'sf_edit_query_args', 'filter_products', 20, 2 );Can S&F be forced to keep using this data?
Thanks!We are in the need to customize a bit more the criteria for fetching using dynamic information during the searches.
We are looking for altering the query posts arguments to exclude some posts from the search.But basically the process of selection of those posts are dynamic and we can’t built it using the UI.
Example:Exclude post which custom meta field ‘ListDate’ is older than two months.
The following code kind of works but leaves all complex filtering counts unaltered in the dropdown filters we have.
Is there a way to make the dropdown filters created to be aware of this update?add_filter( 'sf_edit_query_args', 'kp_exclude_sold_older_than_two_months', 100, 2 ); function kp_exclude_sold_older_than_two_months( $query ) { $time_ago = date('Y-m-d', strtotime('-2 months')); $query['meta_query'] = array( array( 'key' => 'ListDate', 'value' => $time_ago, 'compare' => '>=', 'type' => 'DATE' ) ); return $query; }Thanks in advance.
Pablo.