• Hello, i’m trying to query the upcoming events in the list view only for the current month, i would like to see in the list only the events of current month selected.

    function custom_events_list_query($query) {
      
        if (class_exists('Tribe__Events__Main')) {
            
            if ($query->is_main_query() && is_post_type_archive('tribe_events')) {
                
                $query->set('post_type', 'tribe_events');
                $query->set('posts_per_page', -1);
                $query->set('meta_query', array(
                    array(
                        'key' => '_EventStartDate',
                        'value' => array(
                            date_i18n('Y-m-01 00:00:00'),
                            date_i18n('Y-m-t 23:59:59')
                        ),
                        'compare' => 'BETWEEN',
                        'type' => 'DATETIME',
                    ),
                ));
            }
        }
    }
    
    add_action('pre_get_posts', 'custom_events_list_query');
    

    i have also tried with the tribe_events_pre_get_posts but it doesn’t work . Any suggest ?


    • This topic was modified 9 months, 2 weeks ago by davide90.
    • This topic was modified 9 months, 2 weeks ago by davide90.
    • This topic was modified 9 months, 2 weeks ago by davide90.
  • The topic ‘Upcoming events on list view only for the current month’ is closed to new replies.