Adds a [current_event] shortcode that displays the event that is currently on.
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 | |
/** | |
* Get the HTML to display the current event. | |
* | |
* @param array $args The shortcode arguments. | |
* @param string $template The shortcode template. | |
* @return string | |
*/ | |
function get_current_event_html( $args, $template = false ) { | |
global $wp_theatre; | |
// Get the last event that started. | |
$events = $wp_theatre->events->get( | |
array( | |
'limit' => 1, | |
'end' => 'now', | |
'order' => 'desc', | |
) | |
); | |
// Bail if no events are found. | |
if ( empty( $events) ) { | |
return; | |
} | |
// Bail if last event has already ended. | |
if ( $events[0]->datetime( true ) < time() ) { | |
return; | |
} | |
// Return the HTML of the event. | |
return $events[0]->html( $template ); | |
} | |
add_shortcode('current_event', 'get_current_event_html'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay... Got it figured out!!!!
That would return the last event ever set on each page. So it was doing half of it's job!
By modifying the Get events section to only do the production ID, it just pulls that production!!!
It seems to work for me for now.. I'm going to keep an eye out on this baby. I pulled this section of code from the page where it shows how you can generate your own listing:
Not sure if this was a miscommunication or not, but all is well... for now!