Post Filter by Start & End Date
If you ant to list posts in a specific order and have them auto appear and disappear, this is a simple way to accomplish this. 1. Load ACF for Custom fields and then add 3 custom fields, start_date , end_date and event_date. The field types should be Date Picker. Set the Category you want to use the fields with. 2. Use the Elementor Pro Post widget and set the category you want for the included posts. 3. Load Code Snippets plugin and add the code below. The name of this snippet is Les80 but that can be changed if you change the Query name in the code and the Query field in the Post widget. 4. Enter your Posts and enter the starting and ending date in the ACF fields. That is all it takes. You can use the same Code Snippet for many Post widgets. Just adjust the Category filter part in the Post widget itself.
add_action(‘elementor/query/Les80’, function($query){ $query->set(‘orderby’, ‘event_date’); $query->set(‘order’, ‘ASC’); $meta_query[] = [ [ ‘key’ => ‘start_date’, ‘value’ => date(‘Y.m.d’), //date format set in ACF ‘compare’ => ‘ ‘DATETIME’ ], [ ‘key’ => ‘end_date’, ‘value’ => date(‘Y.m.d’), //date format set in ACF ‘compare’ => ‘>=’, ‘type’ => ‘DATETIME’ ], ]; $query->set( ‘meta_query’, $meta_query ); });

Pops4 Test

Pops3 Test