Skip to content

Instantly share code, notes, and snippets.

@joshfeck joshfeck/events_venue.php
Last active Feb 26, 2018

Embed
What would you like to do?
List of upcoming events for a venue. Requires Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function ee_list_upcoming_events_for_a_venue( $post ) {
// query the events for this venue using EE_Venue's events() method
$query_params = array(
'order_by' => 'Datetime.DTT_EVT_start',
'order' => 'ASC',
array(
'status' => 'publish',
'Datetime.DTT_EVT_start' => array(
'>',
date( current_time( 'mysql' ) ),
'Datetime.DTT_EVT_end' => array(
'<',
date( current_time( 'mysql' ) )
)
)
)
);
$events = EEH_Venue_View::get_venue( $post->ID )->events( $query_params );
// start the output
echo '<h3>Upcoming events at this venue</h3><ul>';
// the loop
foreach ( $events as $event ) {
echo '<li>';
echo '<a href="' . get_permalink( $event->get( 'EVT_ID' ) ) . '">' . $event->get( 'EVT_name' ) . '</a>';
echo '</li>';
}
echo '</ul>';
// end the output
}
// next, add the above to an action found in the venue template
// you could instead use 'AHEE__content_espresso_venues_details_template__before_the_content' to put the list before the content
add_action( 'AHEE__content_espresso_venues_details_template__after_the_content', 'ee_list_upcoming_events_for_a_venue' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.