Remove Event From View on Start Date

Home Forums Calendar Products Events Calendar PRO Remove Event From View on Start Date

  • This topic has 0 replies, 3 voices, and was last updated 8 years ago by AJ Vargas.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1466479
    AJ Vargas
    Participant

    Currently events display until the end date of the event, but I would like for the display to end at the start date. Is there a way to make this change?

    #1467413

    Hi AJ,

    Thanks so much for reaching out!

    The following snippet can shows the event for the first day and remove it from the rest in a multi-day event:

    https://gist.github.com/vicskf/5854eb1f88b8886c39743ca250a4ba99

    Let me know if this helps!

     

    Thanks,

    Jaime

    #1483242
    AJ Vargas
    Participant

    Thank you for that information, but that did not fix the issue I am trying to address. I have attached a screen shot. As you can see the two events published are still showing on the calendar even though they have started. I would like them to automatically drop off the display on the start date. I would only like to display events that can still be registered for.

    #1485454
    Barry
    Member

    Hi AJ,

    I think I understand what you mean.

    It’s worth noting that the calendar purposefully does not do this by default and, to that end, making it happen would require some small amount of custom code to be put in place.

    In general we’re limited as to how far we can go with requests like that, but I’d be happy to offer you a possible starting point:

    add_filter( 'posts_where', function( $sql, $query ) {
    	global $wpdb;
    
    	if ( 'list' !== $query->get( 'eventDisplay' ) ) {
    		return $sql;
    	}
    
    	$start_field = "{$wpdb->postmeta}.meta_value";
    	$start_date  = esc_sql( $query->get( 'start_date' ) );
    
    	return "$sql AND $start_field > '$start_date' ";
    }, 1000, 2 );
    

    The above snippet could be added either to a custom plugin (preferred) or else to your theme’s functions.php file and should do what you want, but note that:

    • It only targets the upcoming list view
    • It is not extensively tested, so I’d recommend some testing before rolling out on your live site

    I hope that helps 🙂

    #1505720
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Remove Event From View on Start Date’ is closed to new replies.