Support

Home Forums Event Espresso Premium Events Table View Template – Display expired event until next morning 8am?

Events Table View Template – Display expired event until next morning 8am?

Posted: December 14, 2017 at 2:41 pm


Rose_P

December 14, 2017 at 2:41 pm

[ESPRESSO_EVENTS_TABLE_TEMPLATE table_search=false category_filter=false table_paging=false show_expired=false template_file=espresso-reps-v2.template.php]

Hi, I’m using a custom Events Table View Template to display a list of upcoming events using the shortcode above. Events will disappear from the list when setting ‘show_expired=false’. That is working fine. Is there a way to set each event to expire (disappear) the next morning at 8am instead of the default time. Ideally, it’d be great to use the ‘Sell Until’ setting to set the time to expire. Thanks!


Josh

  • Support Staff

December 15, 2017 at 1:46 pm

Yes it’s possible but there’s some extra work involved to make that happen.

The first step is you change the shortcode to use show_expired=true, because now you’ll be showing events that may have actually expired, but the “Sell Until” date hasn’t come yet.

Then, the second step is to programmatically set the event to be removed from the list when the Sell Until date comes. You add the code from this snippet to a plugin, then activate the plugin:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/templates/de_ee_filter_events_out_with_expired_tickets.php

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.


Rose_P

December 18, 2017 at 8:02 am

Thank you! We are testing this now. One question: Is it possible to have this work on only one Table View? We have two pages, Upcoming Events (which this code will be implemented), and Past Events (a list of all meetings which have expired).


Josh

  • Support Staff

December 26, 2017 at 3:41 pm

Yes you can. What you do is take those two lines of code that start with
add_filter and move them into a function that checks the current page. Then if it’s the “Upcoming Events” page it will run the filter code.

e.g.

add_action('pre_get_posts','my_check_before_adding_filters', 10);
function my_check_before_adding_filters() {
  if(is_page('upcoming-events')){
      add_filter( 'posts_join', 'de_ee_tweak_event_list_exclude_ticket_expired_events_join', 3, 2 );
      add_filter( 'posts_where', 'de_ee_tweak_event_list_exclude_ticket_expired_events_where', 15, 2 );
  }
}

The support post ‘Events Table View Template – Display expired event until next morning 8am?’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso