I am using The event calendar. I would like to adjust the events. so they don't move over to past events for an hour after they end. So for example, if an event ends at 3 PM EST we don't want it to move to the past events page until 4 PM EST.
In short: I want to set the event end date before 1 hour.
So Evet not going on past.
I have added the below code on the functions.php file
add_filter( 'parse_query', 'posts_filter2',15 );
function posts_filter2( $query ){
$type = 'tribe_events';
if (isset($_GET['post_type'])) {
$type = $_GET['post_type'];
}
if ( 'tribe_events' == $type && $query->get( 'eventDisplay' ) == 'default') {
$queryParamsCounter = 0;
$notification = "2021-04-16 13:06:00";
if (isset($notification)) {
$meta_query['ends-after'] = array(
'key' => '_EventEndDate',
'value' => $notification,
'compare' => '>',
'type' => 'DATETIME',
);
}
$query->set( 'meta_query', $meta_query);
}
}
But still not working.
Does anyone know about this?
Thanks!
I have fixed this issue using parse_query.
I have modified the args of wp_query using a filter hook.
Add below code on functions.php
file
add_filter( 'parse_query', 'posts_filter2',15 );
function posts_filter2( $query ){
$type = 'tribe_events';
if (isset($_GET['post_type'])) {
$type = $_GET['post_type'];
}
if ( 'tribe_events' == $type && $query->get( 'eventDisplay' ) == 'default') {
$queryParamsCounter = 0;
$format = 'Y-m-d G:i:s';
$timezone_name = Tribe__Events__Timezones::wp_timezone_string();
$timezone = new DateTimeZone( $timezone_name );
$current = date_create( '-2 hour', $timezone );
$enddate = date_format($current,"Y-m-d G:i:s");
if (isset($enddate)) {
$meta_query['ends-after'] = array(
'key' => '_EventEndDate',
'value' => $enddate,
'compare' => '>',
'type' => 'DATETIME',
);
}
$query->set( 'meta_query', $meta_query);
}
}
if (isset( $meta_query['ends-after'] ) && $_GET['Recommendation'] != '')
{
$queryParamsCounter++;
$recommendation = $_GET['Recommendation'];
}
Thanks