Problem:
I am looking for a way to have posts shown with number equal to THIS_MONTH() on intial page load by using Views filter hook "wpv_filter_query"
Solution:
You can try filter hook wpv_filter_query like this:
add_filter('wpv_filter_query', 'remove_past_events', 10, 3); function remove_past_events($query_args, $view_settings, $view_id) { if($view_id == 69798 && !isset( $_GET['wpv_view_count'] )) { $time = time(); $this_month = strtotime(date('Y-m-01 00:00:00')); $query_args['meta_query'][] = array(array( 'key' => 'wpcf-program-tidspunkt', 'value' => array($this_month, $time), 'compare' => 'BETWEEN', 'type' => 'NUMERIC,' )); } return $query_args; }
Relevant Documentation:
https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9: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/Hong_Kong (GMT+08:00)
This topic contains 5 replies, has 2 voices.
Last updated by 7 years, 2 months ago.
Assisted by: Luo Yang.