Created
October 19, 2016 16:34
-
-
Save joshfeck/afd53d5a3d2223e9c917f17207c41792 to your computer and use it in GitHub Desktop.
This is a fork of https://gist.github.com/joshfeck/0622e324fb3729880f67. This one includes more event data.
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 | |
// http://code.eventespresso.com/classes/EE_Venue.html#method_events | |
if ( ! is_singular() ) { | |
return; // get out if this is a list of venues | |
} | |
$query_params = array( | |
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 | |
if ( $events ) { | |
echo '<h3>Upcoming events at this venue</h3>'; | |
// the loop | |
foreach ( $events as $event ) { | |
$post_id = $event->get( 'EVT_ID' ); | |
$post_object = get_post( $post_id ); | |
?> | |
<header class="event-header"> | |
<h4 class="entry-title"> | |
<a class="" href="<?php echo get_the_permalink( $post_id ); ?>"> | |
<?php echo get_the_title( $post_id ); ?> | |
</a> | |
</h4> | |
</header> | |
<!-- .event-header --> | |
<div class="event-content"> | |
<?php echo $post_object->post_content;?> | |
</div> | |
<!-- .event-content --> | |
<div class="event-datetimes"> | |
<?php espresso_list_of_event_dates( $post_id );?> | |
</div> | |
<!-- .event-datetimes --> | |
<div class="event-tickets ee-clearfix"> | |
<?php espresso_ticket_selector( $event ); ?> | |
</div> | |
<!-- .event-tickets --> | |
<?php | |
} // the loop | |
} else { | |
echo '<h3>No upcoming events at this venue</h3>'; | |
} | |
// 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to get events from a particular category slug using this method