• Anniechocs

    (@anniechocs)


    Hi, I’m making great use of Events Manager for a few sites, it’s very useful plugin.

    I would like it to be very clear when somebody arrives on a single event page if that event has past.
    People find our past events on Google.

    -Is there a way to get past events to load with a different template, or
    -Do I need to put in a condition to check whether the event date is past into content-event.php?

    Many thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • caimin_nwl

    (@caimin_nwl)

    Hi,

    Glad you’re enjoying the plugin.

    To do this you can use the is_past conditional placeholder:

    https://wp-events-plugin.com/documentation/conditional-placeholders/

    Thread Starter Anniechocs

    (@anniechocs)

    Thanks for your reply. This would be a neat way of doing it, but can you use the conditional placeholders in the php templates?

    Here’s the slightly messy solution I’ve found for the single-event.php template, I expect there’s a nicer way! Any suggestions?

    
    $field = "_event_end_date";
    $enddate =  get_post_meta(get_the_ID(), $field, true);	
    $field = "_event_end_time";
    $endtime =  get_post_meta(get_the_ID(), $field, true);
    
    $enddatetime = $enddate . ' ' . $endtime;
    
    $now = current_time('timestamp');  
    $end = strtotime($enddatetime);
    
    if ($now < $end){
    
    	get_template_part( 'template-parts/content', 'event' );
    
    } else {
    
    	get_template_part( 'template-parts/content', 'pastevent' );
    
    }
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Template for past events’ is closed to new replies.