How to hide past events?

Home Forums Calendar Products Events Calendar PRO How to hide past events?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1234162
    Sebastien
    Participant

    I don’t have many events so hiding the “previous events” link via css is the easiest solution, but for the record how do I completely hide past events? I have read https://theeventscalendar.com/support/forums/topic/hide-past-events/ but adding the suggested code to my child theme functions.php file does not work.
    Thank you.

    #1234879
    George
    Participant

    Hey @sebastien,

    I would recommend a slightly different course of action here.

    First, instead of the snippet shared above, add this code snippet to your theme’s functions.php file:


    add_filter( 'post_class', 'tribe_events_add_past_class_to_events', 10, 3 );

    function tribe_events_add_past_class_to_events( $classes, $class, $post_id ) {

    if ( ! is_array( $classes ) ) {
    return $classes;
    }

    if ( ! tribe_is_event( $post_id ) ) {
    return $classes;
    }

    if ( tribe_is_past_event( $post_id ) ) {
    $classes[] = 'tribe-events--is-past-event';
    }

    return $classes;
    }

    Once that is done, add this CSS to the bottom of your theme’s style.css file:


    .type-tribe_events .tribe-events--is-past-event {
    display: none !important;
    }

    This works well for me and totally hides any past event from your site…let me know if it helps! 😀

    — George

    #1236511
    Sebastien
    Participant

    That works. Thank you!

    #1237681
    George
    Participant

    😀

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘How to hide past events?’ is closed to new replies.