Posted: January 16, 2014 at 8:19 am
|
Hi, I found the Josh script for display past events: <code><ul> <?php global $wpdb; $tablename = $wpdb->prefix . events_detail; $pastevents = $wpdb->get_results("SELECT * FROM $tablename WHERE start_date < curdate() AND event_status <> 'D' "); foreach ( $pastevents as $pastevent ){ echo '<li><a href="' . espresso_reg_url($pastevent->id) . '">' . stripslashes($pastevent->event_name) . '</a></li>'; } ?> </ul></code> If I am right, this snippet should display a list of past event, right? For the single past event, how should be the template? How can I set the page for display the past events? |
Hi there, The snippet will display a list of past events, but it does not group events by category. If you are categorizing the events by year, then you don’t need to use this snippet. The [EVENT_LIST] shortcode will work out of the box for this. |
|
|
I’m not sure if I have understood correctly… Is possible with [EVENT_LIST] to display the past event categorized? |
If the events are assigned to categories, yes. The event list shortcode documentation shows the parameters that you can use to display past events that are in specific categories: https://eventespresso.com/wiki/shortcodes-template-variables/#event-list |
|
|
I need an extra explanation about that. |
|
I solved this getting the data directly from the DB tables: <code>function espresso_custom_template_past_events(){ global $this_event_id, $events, $wpdb; //Get all pasts event data //Get all categories data $sql_cat_name = " SELECT * FROM " . EVENTS_CATEGORY_TABLE; $temp_cats = $wpdb->get_results($sql_cat_name); ?> <ul class="small-block-grid-1 medium-block-grid-3 large-block-grid-4"> <?php foreach ($temp_cats as $category) { ?> <li> <ul> <?php echo '<h3>'.$category->category_name.'</h3>'; $sql_start_end = "SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE end_date < DATE(NOW()) AND category_id =" . $category->id; $temp_start_end = $wpdb->get_results($sql_start_end); //var_dump($temp_start_end); foreach ($temp_start_end as $past_event){ ?> <li> <div class="event"> <div class="title"> <a href="<?php echo espresso_reg_url($past_event->id); ?>"> <?php echo stripslashes_deep($past_event->event_name) ?> </a> </div> </div> </li> <?php } ?> </ul> </li> <?php } ?> </ul> <?php }</code> I need to know one more thing: I want to open the past event in a different template page (not the same for the ACTIVES/OPENS event). I have an archive of pasts event and i want to use the same page to display the past event. In my code I added the How can I open pasts event in a different single event (eventually registration) template? Am I enough clear? Thanks. |
The support post ‘Past event snippet’ 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.