1

after migrating my website to siteground I don't know why my event page doesn't work properly. My past event list and future list are messed up. All list report all events future and past.

My code for future events is:

if (
    $post->post_type=='page' && 
    (
        $post->post_name=='eventi' ||
        $post->post_name=='events'
    )
) {  
    $events = new WP_Query(
        array(
            'post_type' => 'tribe_events',
            'posts_per_page' => -1,
        )
    );
}

and code for past event is:

$past_events = new WP_Query(
    array(
        'posts_per_page'=>-1,
        'eventDisplay'=>'past',
        'post_type' => 'tribe_events'
    )
);

I tried a lot but I can't figure it out. Any help is appreciated, thanks.

1

1 Answer 1

1

For Past events: I have used date functino according to the time zone. Another date can also be added to the wp query.

date_default_timezone_set('America/Winnipeg');
$date2 = date('y-m-d h:i');
$pastEvents = tribe_get_events( [
  'start_date'   => '2014-10-01 00:01',
  'end_date'   => $date2,
  'posts_per_page' => 10,
] );

For Future events:

$pastEvents = array(
  'post_type' => 'tribe_events',
  'post_status' => 'publish',
  'posts_per_page' => 10,
  'order' => 'rand',
  'date_query' => array(
    'before' => 'today', // today can also be replaced by now
    'inclusive' => true
   )
);

for more details visit: date function tribe_get_events

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.