Posted: July 8, 2014 at 5:00 am
|
Hi, I need help. I created a page that display the past events archive, but i need to retrieve the city of the past event. See the code belaow used for this purpose: <code>add_action('action_hook_espresso_custom_template_past-events','espresso_custom_template_past_events'); function espresso_custom_template_past_events(){ global $this_event_id, $events, $wpdb; foreach ($events as $event){ $button_text = __('', 'event_espresso'); $alt_button_text = __('View Details', 'event_espresso');//For alternate registration pages $externalURL = $event->externalURL; $button_text = !empty($externalURL) ? $alt_button_text : $button_text; $registration_url = !empty($externalURL) ? $externalURL : espresso_reg_url($event->id); } //Get all categories data $sql_cat_name = " SELECT * FROM " . EVENTS_CATEGORY_TABLE; $temp_cats = $wpdb->get_results($sql_cat_name); foreach ($temp_cats as $category) { $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); if( !empty($temp_start_end) ) : ?> <li> <ul> <?php echo '<h3>'.$category->category_name.'</h3>'; //Get all pasts event foreach ($temp_start_end as $past_event){ var_dump($past_event); $string = $past_event->event_desc; $match = wp_extract_urls( $string );?> <li class="event"> <div class="title"><?php echo $past_event->event_name; ?></div> <div class="date"><?php past_date_check($past_event); ?></div> <div class="place"> <?php echo do_shortcode('[ESPRESSO_VENUE event_id="' . $event->id . '" show_image="false" show_title="false" show_description="false" show_address="false" show_additional_details="false" show_google_map_link="false" show_map_image="false" outside_wrapper="span" title_wrapper="span" ]'); // if($past_event->city !== ""){ // if($past_event->venue_title !== ""){ // echo $past_event->venue_title . ' - ' . $past_event->city; // }else{ // echo $past_event->city; // } // } ?> </div> <a href="<?php echo stripslashes($match[0]); ?>">Programma</a> <br> <?php if($match[1]) : ?> <a href="<?php echo stripslashes($match[1]); ?>">Relazioni</a> <?php endif; ?> </li> <?php } ?> </ul> </li> <?php endif; } ?></code> |
|
I’m sorry, the correct one is this: <code>add_action('action_hook_espresso_custom_template_past-events','espresso_custom_template_past_events'); function espresso_custom_template_past_events(){ global $this_event_id, $events, $wpdb; foreach ($events as $event){ $button_text = __('', 'event_espresso'); $alt_button_text = __('View Details', 'event_espresso');//For alternate registration pages $externalURL = $event->externalURL; $button_text = !empty($externalURL) ? $alt_button_text : $button_text; $registration_url = !empty($externalURL) ? $externalURL : espresso_reg_url($event->id); } //Get all categories data $sql_cat_name = " SELECT * FROM " . EVENTS_CATEGORY_TABLE; $temp_cats = $wpdb->get_results($sql_cat_name); foreach ($temp_cats as $category) { $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); if( !empty($temp_start_end) ) : ?> <li> <ul> <?php echo '<h3>'.$category->category_name.'</h3>'; //Get all pasts event foreach ($temp_start_end as $past_event){ $string = $past_event->event_desc; $match = wp_extract_urls( $string );?> <li class="event"> <div class="title"><?php echo $past_event->event_name; ?></div> <div class="date"><?php past_date_check($past_event); ?></div> <div class="place"> <?php if($past_event->city !== ""){ if($past_event->venue_title !== ""){ echo $past_event->venue_title . ' - ' . $past_event->city; }else{ echo $past_event->city; } } ?> </div> <a href="<?php echo stripslashes($match[0]); ?>">Programma</a> <br> <?php if($match[1]) : ?> <a href="<?php echo stripslashes($match[1]); ?>">Relazioni</a> <?php endif; ?> </li> <?php } ?> </ul> </li> <?php endif; } ?></code> |
|
Hi, If you are using the Venue Manager then the venue details are held in another table (events_venue) and there is also a relational table (events_venue_rel). You could either do acouple more SQL queries – a request to events_venue_rel to get the associated venue and then a request to events_venue to get the actual venue data. Or you could do a request to events_venue_rel for the associated venue id and then use the ESPRESSO_VENUE shortcode in a do_shortcode() function. https://eventespresso.com/wiki/shortcodes-template-variables/#venue |
|
Thanks Dean, but I REALLY need to solve this problem sooner possible. |
|
Solved! |
|
Glad you got it figured out! |
|
Hi, this line code I need that are in ASC order (by start_date or end_date), but the start_date or end_date column is a string type. How can i display all past event ordered by ASC start or end date? Thanks |
|
This is an example |
Hi Daniele, You’ll want to use the ‘ORDER BY’ SQL Keyword. Basically add: ‘ORDER BY date(start_date), id ASC’ To the end of the Query. So something like: $sql_past_events = "SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE end_date < DATE(NOW()) AND category_id =" . $category->id . " ORDER BY date(start_date), id ASC"; Should work as you are expecting. |
|
|
Thank you very very much!! Mi mistake was to write |
You are most welcome Daniele 🙂 I will mark this thread resolved, if you do have any other questions feel free to start another. |
|
The support post ‘Displaying event city on past events list’ 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.