hide events that have started already

Home Forums Calendar Products Events Calendar PRO hide events that have started already

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #1046655
    Matthew
    Participant

    Hi,

    I want to hide events that have already started in the list and map view. This thread explains how to do it:

    Hide ongoing events in Photo/List view, still visible in categories

    Unfortunately, I lack the coding skill to create the modification with the info in that thread. I was wondering if @Josh could expand on how to write the code to put in the template files for list view and map view that I will drop into my child theme? A code snippet that I could just drop in the template files would be awesome 🙂

    Thanks,
    Mat

    #1049754
    Josh
    Participant

    Hey Mat,

    Thanks for reaching out to us!

    Let me see what I can do! First, is this in reference to something like a multi-day event that you would like hidden after the event has started? Or is this for any type of event, for example an event that starts at 8:00am you would like removed from the calendar if it is 8:30am even if that event is set to last until 4:00pm?

    Thanks!

    #1049788
    Jennifer Wilder
    Participant

    I have the same issue. Many art exhibits runs for months and always show up first. I used Photo view as the default for a long time because the page presented with ‘Upcoming Events’ and didn’t show a specific start month rather than list view where the page showed upcoming events as the header, but the list started with the oldest start date of a currently running event. Right now the list loops back to March, 2015.

    I would like to show the events in the list and not hide them, but have the month reflect the current month instead of the month it started.

    To that end, I’ve been using month view with sticky events. Not ideal in my visual world, but less confusing to viewers.

    This has been a thorn for me for two years but since I don’t know code, I didn’t know what to do. Would an enhancement be useful for the community?

    Thanks.
    Jenny

    #1050272
    Matthew
    Participant

    Hi Josh,

    It is for multi-date events. So if the calendar didn’t display events with a start date before the current date that would solve the issue (it is fine to display events that started earlier that day).

    Does that make sense?

    Thanks,
    Mat

    #1051325
    Josh
    Participant

    Hey!

    Following the Themer’s Guide referenced above, you can copy the src > views > month > single-event.php template into your theme and replace the code at the very bottom of the file with the following:

    
    <?php if( ! tribe_event_is_multiday() ) { ?>
    	<div id="tribe-events-event-<?php echo esc_attr( $event_id ); ?>" class="<?php tribe_events_event_classes() ?>" data-tribejson='<?php echo esc_attr( tribe_events_template_data( $post ) ); ?>'>
    	<h3 class="tribe-events-month-event-title"><a href="<?php echo esc_url( $link ) ?>" class="url"><?php echo $title ?></a></h3>
    </div><!-- #tribe-events-event-# -->
    <?php
    }
    

    Let me know if this helps.
    Thanks!

    #1051891
    Matthew
    Participant

    Hi Josh,

    I tried putting that code in the month view (in my child theme). It doesn’t seem to have stopped events that have started showing up. You can see the code in my child theme here:

    https://nimbus.everhelper.me/client/notes/share/365686/hBCMU9y3qKIVHE5UwXamWc7qdqbG0LKE/

    Actually, I only use the list and map view. I found the single.event.php in /wp-content/plugins/the-events-calendar/src/views/list but when I opened it I had no idea where to put your snippet! 🙂

    So I have 2 questions.

    1 – Why did the snippet I set up for month view not work?
    2 – How do I edit the list and map views to prevent events that have started from showing?

    Thanks again Josh,
    Mat

    #1052746
    Josh
    Participant

    Hey Matthew,

    Thanks for following up with us!

    The first thing to check if the code isn’t showing is to verify that the file is in the correct folder structure within your theme and matches where it was in the plugin. Do you mind typing out the folder structure that is currently used for the snippet?

    For each of the other views, they have their own “single-event.php” file within their associated folders. You can wrap the entire display portions of those with the same “tribe_event_is_multiday()” conditional from the above snippet.

    Let me know if this helps.

    Thanks!

    #1053602
    Matthew
    Participant

    Hi Josh,

    This is the folder I put it in:

    pootlepress-child-theme/tribe-events/month/single-event.php

    You can see exactly how I formatted it in that screenshot.

    What am I missing?

    Cheers,
    Mat

    #1054718
    Josh
    Participant

    Hey Mat,

    Thanks for following up!

    The location within the theme looks correct and the code looks like it was added correctly as well. However, the it looks like I do need to update the snippet I provided to accomplish specifically what you’re looking for (showing the first day of a multiday event but not the other days).

    But, to test if the code is actually getting implemented onto your site, if you create an all-day event with a start date of today and an end date of this Friday does that appear on your calendar? It shouldn’t show at all on the month view based on the snippet provided. Is that what you’re seeing?

    Thanks!

    #1055055
    Matthew
    Participant

    Hi Josh,

    Actually month view is behaving very strangely now. I created a test event with start date today and end on friday (all day event). As you said it did not show. I changed the start date tomorrow to check that it would show up, it did not. I changed the end date to the same as the start date (one-day all day event) and it shows up. I made the event start on friday at 9am and end on sunday ay 6pm and it disappeared again. I deleted the snippet and events lasting more than a single day show up again as normal.

    Essentially, the snippet seems to prevent any event that spans multiple days from showing up in the month view (it also hides all my other non-test multi-day events). The events show up in the list view as normal.

    Cheers,
    Mat

    #1056139
    Josh
    Participant

    Hey Matthew,

    I apologize, that would actually be the expected display based on that previous snippet. Here is the updated snippet that should do what you’re looking for:

    
    <?php
    $start_date = tribe_get_start_date( $post->ID, false, 'U' );
    $current_day = time();
    
    if( tribe_event_is_multiday() && $start_date > $current_day ) { ?>
    	<div id="tribe-events-event-<?php echo esc_attr( $event_id ); ?>" class="<?php tribe_events_event_classes() ?>" data-tribejson='<?php echo esc_attr( tribe_events_template_data( $post ) ); ?>'>
    		<h3 class="tribe-events-month-event-title"><a href="<?php echo esc_url( $link ) ?>" class="url"><?php echo $title ?></a></h3>
    	</div><!-- #tribe-events-event-# -->
    <?php
    }
    

    Let me know if this helps.
    Thnanks!

    #1056661
    Matthew
    Participant

    Hi Josh,

    That seems to be working perfectly on month view now, thanks.

    How do I get it to work on list and map views? It is still displaying events that have already started in list view currently. The code in /wp-content/plugins/the-events-calendar/src/views/list/single-event.php is very different from /wp-content/plugins/the-events-calendar/src/views/month/single-event.php and I can’t find any template for map view.

    Thanks,
    Mat

    #1056904
    Josh
    Participant

    Hey Mat,

    For any of the views, before the event information is called you can get the variables and the conditional “if” statement and wrap it around the single event:

    
    $start_date = tribe_get_start_date( $post->ID, false, 'U' );
    $current_day = time();
    
    if( tribe_event_is_multiday() && $start_date > $current_day ) {...}
    

    and this would control the output of multiday events the way you would like.

    Let me know if this helps.

    Thanks!

    #1057215
    Matthew
    Participant

    Hi Josh,

    Thanks for continuing with this for me. I’m afraid I don’t know how to write code so I didn’t really understand your last comment. I had a try anyway and modified the snippet to the following:

    <?php 
    $start_date = tribe_get_start_date( $post->ID, false, 'U' );
    $current_day = time();
     
    if( tribe_event_is_multiday() && $start_date > $current_day ) { ?>
    <div id="tribe-events-event-<?php echo esc_attr( $event_id ); ?>" class="<?php tribe_events_event_classes() ?>" data-tribejson='<?php echo esc_attr( tribe_events_template_data( $post ) ); ?>'>
    <h3 class="tribe-events-month-event-title"><a href="<?php echo esc_url( $link ) ?>" class="url"><?php echo $title ?></a></h3>
    </div><!-- #tribe-events-event-# -->
    <?php
    }

    Unfortunately that did not work. The month view continues to only show events that have yet to start but the list view still shows events that have already started.

    Was the way I wrote the code wrong?

    Thanks,
    Mat

    #1057858
    Josh
    Participant

    Hey Mat,

    You can edit the “single-event.php” file (by following our Themer’s Guide and copying the file into your theme) within the “list” folder and replace all of the file’s contents with the following:

    https://gist.github.com/BeardedGinger/88fa32b3893839c0e3ca

    You can then follow the example here for any of the other views that you’d like to modify.

    Thanks!

Viewing 15 posts - 1 through 15 (of 19 total)
  • The topic ‘hide events that have started already’ is closed to new replies.