Second issue: In the frontend the timestamp is pre-selected. However, you must click Submit for this filter to be activated (or changing a filter when using ajax refresh on filter change). So we think, there should be an automatic refresh on frontend, when a default date is set. Please see my screenshot for reference. Best regards, Christian.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
You can use the Toolset Views/Blocks "wpv_filter_query" hook to filter the view results on fly.
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
You can add the following code to "Custom Code" section offered by Toolset:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/
add_filter( 'wpv_filter_query', 'func_filterby_default_today_date', 99, 3 );
function func_filterby_default_today_date( $query, $view_settings, $view_id ) {
if( !is_admin() and $view_id == 99999) {
/// default today time
$selected_start = strtotime('0:00:00');
$date_field_slug = 'session-date';
if(!isset($query['meta_query']) ) {
$args = array(
'relation' => 'AND',
array(
'key' => 'wpcf-'.$date_field_slug ,
'value' => $selected_start,
'compare' => '>=',
'type' => 'numeric'
)
);
// add these arguments to your meta query
$query['meta_query'] = isset($query['meta_query']) ? $query['meta_query'] : [];
$query['meta_query'][] = $args;
}
}
return $query;
}
- Replace 99999 with your original view ID
- Replace $date_field_slug value with your original custom date field slug
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
If your issue is resolved - you're welcome to mark resolve this ticket.