Skip to content

Instantly share code, notes, and snippets.

@Apina
Last active December 15, 2015 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Apina/568dbb38be956f314a64 to your computer and use it in GitHub Desktop.
Save Apina/568dbb38be956f314a64 to your computer and use it in GitHub Desktop.
Shortcode to show the event countdown - basic version
/*
Shortcode Name: Event Countdown
Author: Dean Robinson
Description: This code uses the espresso_countdown function in time_date.php to display a countdown to the event start date
Usage Example: [EVENT_COUNTDOWN]
Requirements:
Notes: This needs to be added to the custom_shortcodes.php file that comes with the Custom Files Addon
*/
function ee_event_countdown() {
global $this_event_id;
$event_id = $this_event_id;
//Create the countdown variables
$start_timestamp = espresso_event_time($event_id, 'start_timestamp');
$end_timestamp = espresso_event_time($event_id, 'end_timestamp');
$countdown = espresso_countdown($start_timestamp, $end_timestamp, 'This event has ended' );
//Display the countup
return $countdown;
}
add_shortcode('EVENT_COUNTDOWN', 'ee_event_countdown');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment