Forums › Forums › Search & Filter Pro › No Results – DateTime Range
Tagged: date
- This topic has 7 replies, 2 voices, and was last updated 5 years, 8 months ago by Anonymous.
-
Anonymous(Private) March 30, 2019 at 2:56 pm #206995
Would it be possible to intercept the query and alter the query using sf_edit_query_args.
I would do something like this in that filter
$start = '2016-01-01 00:00:00'; $end = '2016-12-31 23:59:59'; $query_args['meta_key'] = '_audiotheme_gig_datetime'; $query_args['meta_query'] = array( 'key' => '_audiotheme_gig_datetime', 'value' => array( $start, $end ), 'compare' => 'BETWEEN', );
Ideally I just need to alter the query prior with my own arguments around a specific meta field.
Anonymous(Private) March 30, 2019 at 3:42 pm #207000I’ve made some progress with this.
I can alter the query by adjusting the meta_query as above but I need to remove a fields value from $sf_current_query. When I unset it the query is still run like it’s there.
I removed it like this
unset($sf_current_query['_sfm__audiotheme_gig_datetime']);
Anonymous(Private) April 2, 2019 at 3:14 am #207161Yes, and the element was removed, but it had no effect on the query. It still processed it as if the element was in the query.
So I had to work around it by unsetting the element that was set in the $_GET variable. It works for now, but I was sure it would have been straight forward using the sf_edit_query_args function.
-
AuthorPosts