Skip Navigation

[Resolved] Multiple Date (Custom Field) Filter

This thread is resolved. Here is a description of the problem and solution.

Problem:
Multiple Date (Custom Field) Filter

Solution:
If you by default want to filter the posts compare to your custom date field for the future posts - you need to use the view's filter: wpv_filter_query

You can find the proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/multiple-date-custom-field-filter/#post-1351429

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/views-filters/#wpv_filter_query

This support ticket is created 5 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 4.70 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by philippR-2 5 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1351069

Hey Toolset Helpers!

TOPIC: Multiple Date (Custom Field) Filter

i Have a filter for a custom field DATE. At the Moment i filter for the Date with equl to a URL Param. Now i want to add a filter that shows only future CPTs (defined in the Custom Date field) but i cant add another date Filter for the Custom Date Field. Does anyone know a solution?

#1351429

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You should not be able to add multiple filters for the same custom field using the GUI.

If you by default want to filter the posts compare to your custom date field for the future posts - you need to use the view's filter: wpv_filter_query
=> https://toolset.com/documentation/user-guides/views-filters/#wpv_filter_query

add_filter('wpv_filter_query', 'func_remove_past_posts', 10, 3);
function func_remove_past_posts($query_args, $view_settings, $view_id) {
   
if($view_id == 9999)  {
$time = time();  
$query_args['meta_query'][] = array(array(
'key' => 'wpcf-your_field_slug',
'value' => $time,
'compare' => '>=',
'type' => 'NUMERIC,'
 ));
}
   
return $query_args;
}

Where:
- Repalce 9999 with your original view ID
- Replace "your_field_slug" with your original field slug

Please check the following related ticket that may help you:
=> https://toolset.com/forums/topic/set-datepicker-to-today-by-default-and-enabled-on-initial-page-load/#post-484523

#1354573

Thx! Worked perfect - the only downside of this one is - in the Filter Bars the PAST Dates in the Dropdown are still there