Forums › Forums › Search & Filter Pro › Use single date input as lower bound for date meta
Tagged: date meta query compare filter, V3
- This topic has 5 replies, 2 voices, and was last updated 4 years, 7 months ago by Trevor.
-
Anonymous(Private) April 2, 2020 at 2:34 pm #238762
I’m trying to figure out whether it’s possible to use a single date input as a lower bound for posts containing a ‘start date’ meta, so that if I input for example 2020-04-15 it will return me all posts having a start date of that AND later in the future. Right now it only returns posts having exactly that start date.
If I add a filter to sf_edit_query_args, I can’t see the date or any meta query arguments entered in the search form, same goes for the sf_main_query_pre_get_posts filter. Is it possible to hook in anywhere to change the meta_compare type of the query for the start date meta key?
Trevor(Private) April 2, 2020 at 2:58 pm #238785It is, by a small hack. Set the field up as a date range and then, in the form in the front end, use custom CSS to hide the display of the To field.
You will also need some PHP to add a distant date into the To field in the query arguments, using this filter (which I think you know already):
https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments
Anonymous(Private) April 6, 2020 at 3:10 pm #239148How would I go about adding the To-date into the query? This is the query args that I get when I add the sf_edit_query_args filter (even with dates put in):
Array ( [paged] => 1 [search_filter_id] => 144 [search_filter_override] => [posts_per_page] => 10 [post_status] => Array ( [0] => publish ) [meta_query] => Array ( ) [post_type] => cursus [post__in] => Array ( [0] => 0 ) )
I can’t see any of the form inputs here, the only thing that seems to change is when I put in a search word, the [s]-arg is added.
-
AuthorPosts