Last active
February 26, 2018 23:58
-
-
Save joshfeck/0622e324fb3729880f67 to your computer and use it in GitHub Desktop.
List of upcoming events for a venue. Requires Event Espresso 4.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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